@@ -71,7 +71,7 @@ public JsonHttpResponseHandler(boolean useRFC5179CompatibilityMode) {
71
71
/**
72
72
* Creates new JsonHttpResponseHandler with given JSON String encoding and RFC5179CompatibilityMode
73
73
*
74
- * @param encoding String encoding to be used when parsing JSON
74
+ * @param encoding String encoding to be used when parsing JSON
75
75
* @param useRFC5179CompatibilityMode Boolean mode to use RFC5179 or latest
76
76
*/
77
77
public JsonHttpResponseHandler (String encoding , boolean useRFC5179CompatibilityMode ) {
@@ -147,17 +147,17 @@ public void run() {
147
147
@ Override
148
148
public void run () {
149
149
// In RFC5179 a null value is not a valid JSON
150
- if (!useRFC5179CompatibilityMode && jsonResponse == null ){
150
+ if (!useRFC5179CompatibilityMode && jsonResponse == null ) {
151
151
onSuccess (statusCode , headers , (String ) jsonResponse );
152
- }else if (jsonResponse instanceof JSONObject ) {
152
+ } else if (jsonResponse instanceof JSONObject ) {
153
153
onSuccess (statusCode , headers , (JSONObject ) jsonResponse );
154
154
} else if (jsonResponse instanceof JSONArray ) {
155
155
onSuccess (statusCode , headers , (JSONArray ) jsonResponse );
156
156
} else if (jsonResponse instanceof String ) {
157
157
// In RFC5179 a simple string value is not a valid JSON
158
- if ( useRFC5179CompatibilityMode ){
158
+ if (useRFC5179CompatibilityMode ) {
159
159
onFailure (statusCode , headers , (String ) jsonResponse , new JSONException ("Response cannot be parsed as JSON data" ));
160
- }else {
160
+ } else {
161
161
onSuccess (statusCode , headers , (String ) jsonResponse );
162
162
}
163
163
} else {
@@ -198,9 +198,9 @@ public void run() {
198
198
@ Override
199
199
public void run () {
200
200
// In RFC5179 a null value is not a valid JSON
201
- if (!useRFC5179CompatibilityMode && jsonResponse == null ){
201
+ if (!useRFC5179CompatibilityMode && jsonResponse == null ) {
202
202
onFailure (statusCode , headers , (String ) jsonResponse , throwable );
203
- }else if (jsonResponse instanceof JSONObject ) {
203
+ } else if (jsonResponse instanceof JSONObject ) {
204
204
onFailure (statusCode , headers , throwable , (JSONObject ) jsonResponse );
205
205
} else if (jsonResponse instanceof JSONArray ) {
206
206
onFailure (statusCode , headers , throwable , (JSONArray ) jsonResponse );
@@ -251,24 +251,21 @@ protected Object parseResponse(byte[] responseBody) throws JSONException {
251
251
String jsonString = getResponseString (responseBody , getCharset ());
252
252
if (jsonString != null ) {
253
253
jsonString = jsonString .trim ();
254
- if (jsonString .startsWith (UTF8_BOM )) {
255
- jsonString = jsonString .substring (1 );
256
- }
257
- if ( useRFC5179CompatibilityMode ){
254
+ if (useRFC5179CompatibilityMode ) {
258
255
if (jsonString .startsWith ("{" ) || jsonString .startsWith ("[" )) {
259
256
result = new JSONTokener (jsonString ).nextValue ();
260
257
}
261
- }else {
258
+ } else {
262
259
// Check if the string is an JSONObject style {} or JSONArray style []
263
260
// 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 ("]" )) {
266
263
result = new JSONTokener (jsonString ).nextValue ();
267
264
}
268
265
// Check if this is a String "my String value" and remove quote
269
266
// 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 );
272
269
}
273
270
}
274
271
}
0 commit comments