I am new in json and I have to get the value from web service response. I have used org.json library for this.Below is the sample json value:
{"tms_guid": "9LaHmoHpmTd811R",
"recharge_status": "100",
"message": "Transaction Successful",
"response_time": {
"verifyClient": 0.0281,
"verifyGuid": 0.8695,
"verifyOperator": 0.8698,
"verifyMsid": 0.8698,
"tms_guid": 1.6971,
"queryErr": 7.4243,
"StoringRecharge": 7.4358,
"UpdatingBalance": 7.448
}
}
My parsing JSON input string is :
private final static String JSON_TEST_DATA
= "{"
+ " \"tms_guid\": \"9LaHmoHpmTd811R\", "
+ " \"recharge_status\": \"100\", "
+ " \"message\": \"Transaction Successful\", "
+ " \"response_time\": { "
+ " \"verifyClient\": 0.0281, "
+ " \"verifyGuid\": 0.8695, "
+ " \"verifyOperator\": 0.8698,"
+ " \"verifyMsid\": 0.8698,"
+ " \"tms_guid\": 1.6971,"
+ " \"queryErr\": 7.4243,"
+ " \"StoringRecharge\": 7.4358,"
+ " \"UpdatingBalance\": 7.448"
+ " }"
+ "}";
public static void main(final String[] argv) throws JSONException {
System.out.println(JSON_TEST_DATA);
final JSONObject testObj = new JSONObject(JSON_TEST_DATA);
System.out.println(testObj.toString());
}
Exception is as follows:
Exception in thread "main" org.json.JSONException: Expected a ':' after a key at 5 [character 6 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:432)
at org.json.JSONObject.<init>(JSONObject.java:206)
at org.json.JSONObject.<init>(JSONObject.java:310)
at com.kalsym.wsp.sp.icebeep.TestIceBeep.main(TestIceBeep.java:73)
I have seen similar post. But could not figure about the solution.