diff options
Diffstat (limited to 'src/org/happysanta/gd/API/Response.java')
-rw-r--r-- | src/org/happysanta/gd/API/Response.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/org/happysanta/gd/API/Response.java b/src/org/happysanta/gd/API/Response.java new file mode 100644 index 0000000..827fae4 --- /dev/null +++ b/src/org/happysanta/gd/API/Response.java @@ -0,0 +1,26 @@ +package org.happysanta.gd.API; + +import org.happysanta.gd.API.*; +import org.json.JSONArray; +import org.json.JSONException; + +public class Response { + + JSONArray jsonArray; + + public Response(String result) throws JSONException, APIException { + jsonArray = new JSONArray(result); + if (!isOK()) { + throw new APIException(jsonArray.getString(1)); + } + } + + public boolean isOK() throws JSONException { + return jsonArray.getString(0).equals("ok"); + } + + public JSONArray getJSON() { + return jsonArray; + } + +} |