Parsing JSON array and object in Android

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

This is what the JSON looks like:

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


        
6条回答
  •  忘掉有多难
    2021-01-07 15:40

    Your root object is a JSON array [], not a JSON object {} there. So, you need

    jObj = new JSONArray(jsonStr);
    jObj = jObj.getJSONObject(0);
    

    The rest of your code will now work fine treating jObj as a JSONObject. The concept here is exactly the same as what you're doing for your properties JSON array.

提交回复
热议问题