Skip to content

Commit fccf6f2

Browse files
committed
Code formatting, removed duplicate UTF8_BOM removal code
1 parent 929a895 commit fccf6f2

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public JsonHttpResponseHandler(boolean useRFC5179CompatibilityMode) {
7171
/**
7272
* Creates new JsonHttpResponseHandler with given JSON String encoding and RFC5179CompatibilityMode
7373
*
74-
* @param encoding String encoding to be used when parsing JSON
74+
* @param encoding String encoding to be used when parsing JSON
7575
* @param useRFC5179CompatibilityMode Boolean mode to use RFC5179 or latest
7676
*/
7777
public JsonHttpResponseHandler(String encoding, boolean useRFC5179CompatibilityMode) {
@@ -147,17 +147,17 @@ public void run() {
147147
@Override
148148
public void run() {
149149
// In RFC5179 a null value is not a valid JSON
150-
if(!useRFC5179CompatibilityMode && jsonResponse == null){
150+
if (!useRFC5179CompatibilityMode && jsonResponse == null) {
151151
onSuccess(statusCode, headers, (String) jsonResponse);
152-
}else if (jsonResponse instanceof JSONObject) {
152+
} else if (jsonResponse instanceof JSONObject) {
153153
onSuccess(statusCode, headers, (JSONObject) jsonResponse);
154154
} else if (jsonResponse instanceof JSONArray) {
155155
onSuccess(statusCode, headers, (JSONArray) jsonResponse);
156156
} else if (jsonResponse instanceof String) {
157157
// In RFC5179 a simple string value is not a valid JSON
158-
if ( useRFC5179CompatibilityMode){
158+
if (useRFC5179CompatibilityMode) {
159159
onFailure(statusCode, headers, (String) jsonResponse, new JSONException("Response cannot be parsed as JSON data"));
160-
}else{
160+
} else {
161161
onSuccess(statusCode, headers, (String) jsonResponse);
162162
}
163163
} else {
@@ -198,9 +198,9 @@ public void run() {
198198
@Override
199199
public void run() {
200200
// In RFC5179 a null value is not a valid JSON
201-
if (!useRFC5179CompatibilityMode && jsonResponse == null){
201+
if (!useRFC5179CompatibilityMode && jsonResponse == null) {
202202
onFailure(statusCode, headers, (String) jsonResponse, throwable);
203-
}else if (jsonResponse instanceof JSONObject) {
203+
} else if (jsonResponse instanceof JSONObject) {
204204
onFailure(statusCode, headers, throwable, (JSONObject) jsonResponse);
205205
} else if (jsonResponse instanceof JSONArray) {
206206
onFailure(statusCode, headers, throwable, (JSONArray) jsonResponse);
@@ -251,24 +251,21 @@ protected Object parseResponse(byte[] responseBody) throws JSONException {
251251
String jsonString = getResponseString(responseBody, getCharset());
252252
if (jsonString != null) {
253253
jsonString = jsonString.trim();
254-
if (jsonString.startsWith(UTF8_BOM)) {
255-
jsonString = jsonString.substring(1);
256-
}
257-
if ( useRFC5179CompatibilityMode){
254+
if (useRFC5179CompatibilityMode) {
258255
if (jsonString.startsWith("{") || jsonString.startsWith("[")) {
259256
result = new JSONTokener(jsonString).nextValue();
260257
}
261-
}else{
258+
} else {
262259
// Check if the string is an JSONObject style {} or JSONArray style []
263260
// If not we consider this as a string
264-
if (( jsonString.startsWith("{") && jsonString.endsWith("}") )
265-
|| jsonString.startsWith("[") && jsonString.endsWith("]") ) {
261+
if ((jsonString.startsWith("{") && jsonString.endsWith("}"))
262+
|| jsonString.startsWith("[") && jsonString.endsWith("]")) {
266263
result = new JSONTokener(jsonString).nextValue();
267264
}
268265
// Check if this is a String "my String value" and remove quote
269266
// Other value type (numerical, boolean) should be without quote
270-
else if ( jsonString.startsWith("\"") && jsonString.endsWith("\"") ){
271-
result = jsonString.substring(1,jsonString.length()-1);
267+
else if (jsonString.startsWith("\"") && jsonString.endsWith("\"")) {
268+
result = jsonString.substring(1, jsonString.length() - 1);
272269
}
273270
}
274271
}

0 commit comments

Comments
 (0)