I'm new to JSON.
I need to receive a response (in form of a String) from a server. That response can be an object like
{"a" : "value", "b" : "value2", ...}
if the request was successful, or a single string like
"ERROR"
on error.
Using org.json.JSONObject
, how do I check which one has been returned?
EDIT
I think this could work, but I'm not sure if this is the right way to do it
if(JSONString.equals("\"ERROR\"") {
//handle error
} else {
//parse actual object
}
Where JSONString
is a String containing the server response
Could this work?