Android: Issue With Jsonarray Parsing
I am new to android and stuck with some problem in Json parsing. JSONArray resultJsonArray = data.getJSONArray('detailsArr'); getJSONArray is showing in red colour it means some i
Solution 1:
According to your JSON
it should be
JSONArray resultJsonArray = data.getJSONArray("result");
Since result is the name of the array.
Solution 2:
I did't find detailsArr
.
JSONObject reader = newJSONObject(Your_Json_Sring);
JSONArray jsonArray = reader.getJSONArray("result");
for (int i = 0; i < jsonArray.length(); i++)
{
JSONObject e = jsonArray.getJSONObject(i);
String conversation = e.getString("conversation");
}
Solution 3:
Bundle doesn't have a method getJSONArray()
And your JSON string doesn't contain a key named detailsArr
.
UPDATE:
I think what you want to do is this:
JSONArray resultJsonArray = newJSONObject(data.getString("detailsArr"))
.getJSONArray("result");
Solution 4:
Try following things:
Check imports, it should be like (if you are using other library - should be similar)
import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject;
Check if you data is type of
JSONObject
.
Solution 5:
Step 1: Using this Link Create one Pojo for your Json String.
Step 2: put following in your gradle than sync your gradle file
compile'com.google.code.gson:gson:2.4'
Step :3 and at Last Use following code for deserialized Json
GsonmGson=newGson();
JsonReaderreader=newJsonReader(newStringReader(YOUR_JSON_STRING));
finalYOUR_POJO_CLASS_NAMEmList= mGson.fromJson(reader, newTypeToken<YOUR_POJO_CLASS_NAME>() {
}.getType());
I hope your are clear with my solution. Best of Luck
Post a Comment for "Android: Issue With Jsonarray Parsing"