Parsing JSON array and object in Android

前端 未结 6 1958
渐次进展
渐次进展 2021-01-07 15:22

This is what the JSON looks like:

[{
    \"pmid\": \"2\",
    \"name\": \" MANAGEMENT\",
    \"result\": \"1\",
    \"properties\": [
        {
            \         


        
6条回答
  •  渐次进展
    2021-01-07 15:59

    As in posted json String jsonStr is JSONArray of JSONObeject's instead of JOSNObject of JSONArray.

    So convert jsonStr String to JSONArray:

    JSONArray jArray = new JSONArray(jsonStr);
    JSONObject c = jArray.getJSONObject(0);
    // get properties JSONArray from c
     JSONArray jArrProperties = c.getJSONArray("properties");
     JSONObject jsonObject = jArrProperties.getJSONObject(0);
    

提交回复
热议问题