I have a little question about parsing a JSON string in Android. I'm trying to parse this JSON :
{
"error":504,
"result":"[\"USRL3C4NAEL84727\",\"USR1HZE4UN5289H1\",\"USR46476WQB92M84\",\"USR4ZQ193YGRK782\"]"
}
The part that I need actually is to parse the result
. I did try this :
JSONObject jObj = new JSONObject(responseString);
int error = Integer.parseInt(jObj.optString("error","0"));
String errorMessage = jObj.optString("result","");
if(error==504){
JSONArray savedCodes = jObj.getJSONArray("result");
for (int i = 0; i < savedCodes.length(); i++) {
String returnString = savedCodes.getString(i);
Log.e("","returnString : "+returnString);
}
}
But it's throwing me an exception :
org.json.JSONException: Value ["USR9BA13IZG27H93","USRI818369RH919Y","USRWT7612CQV4375","USR7739R644X84A1"] at result of type java.lang.String cannot be converted to JSONArray
So I guess it's not JSONArray
and I need to know how to parse the result part and get this at the end :
String 1 = USR9BA13IZG27H93
String 2 = USRI818369RH919Y
and etc...
Any solutions?