Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make json response parsing overridable by children

  • Loading branch information...
commit 2168f7c264e7218dd37a769a52df789c728107b0 1 parent dbedb9d
James Smith authored May 23, 2011
10  src/com/loopj/android/http/JsonHttpResponseHandler.java
@@ -18,8 +18,6 @@
18 18
 
19 19
 package com.loopj.android.http;
20 20
 
21  
-import java.io.IOException;
22  
-
23 21
 import org.json.JSONArray;
24 22
 import org.json.JSONException;
25 23
 import org.json.JSONObject;
@@ -31,7 +29,7 @@ public void handleSuccessMessage(String responseBody) {
31 29
         super.handleSuccessMessage(responseBody);
32 30
 
33 31
         try {
34  
-            Object jsonResponse = new JSONTokener(responseBody).nextValue();
  32
+            Object jsonResponse = parseResponse(responseBody);
35 33
             if(jsonResponse instanceof JSONObject) {
36 34
                 onSuccess((JSONObject)jsonResponse);
37 35
             } else if(jsonResponse instanceof JSONArray) {
@@ -41,7 +39,11 @@ public void handleSuccessMessage(String responseBody) {
41 39
             onFailure(e);
42 40
         }
43 41
     }
44  
-
  42
+    
  43
+    protected Object parseResponse(String responseBody) throws JSONException {
  44
+        return new JSONTokener(responseBody).nextValue();
  45
+    }
  46
+    
45 47
     // Public callbacks
46 48
     public void onSuccess(JSONObject response) {}
47 49
     public void onSuccess(JSONArray response) {}

0 notes on commit 2168f7c

Please sign in to comment.
Something went wrong with that request. Please try again.