I have the following method for parsing a sample String to JSONObject:
private JSONObject test() {
try {
String responseData = "{\"m_tani\":[{\"tani_cd\":\"02\",\"tani_nm\":\"cs\"},{\"tani_cd\":\"03\",\"tani_nm\":\"pc\"}]}";
Log.i("Json", responseData.toString());
JSONObject json = new JSONObject(responseData);
return json;
} catch (Exception e) {
e.printStackTrace();
Log.i("Json", "exception");
}
Log.i("Json", null);
return null;
}
The responseData is:
{"m_tani":[{"tani_cd":"02","tani_nm":"cs"},{"tani_cd":"03","tani_nm":"pc"}]}
When I debug it, from the line JSONObject json = new JSONObject(responseData); it jumps to return null;, not return json; or catch(Exception e).
I don't know why, please help me with this
JSONObjectin first line and change last linereturn json;