Skip to content

Commit 2168f7c

Browse files
committed
Make json response parsing overridable by children
1 parent dbedb9d commit 2168f7c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package com.loopj.android.http;
2020

21-
import java.io.IOException;
22-
2321
import org.json.JSONArray;
2422
import org.json.JSONException;
2523
import org.json.JSONObject;
@@ -31,7 +29,7 @@ public void handleSuccessMessage(String responseBody) {
3129
super.handleSuccessMessage(responseBody);
3230

3331
try {
34-
Object jsonResponse = new JSONTokener(responseBody).nextValue();
32+
Object jsonResponse = parseResponse(responseBody);
3533
if(jsonResponse instanceof JSONObject) {
3634
onSuccess((JSONObject)jsonResponse);
3735
} else if(jsonResponse instanceof JSONArray) {
@@ -41,7 +39,11 @@ public void handleSuccessMessage(String responseBody) {
4139
onFailure(e);
4240
}
4341
}
44-
42+
43+
protected Object parseResponse(String responseBody) throws JSONException {
44+
return new JSONTokener(responseBody).nextValue();
45+
}
46+
4547
// Public callbacks
4648
public void onSuccess(JSONObject response) {}
4749
public void onSuccess(JSONArray response) {}

0 commit comments

Comments
 (0)