Parse JSON object with string and value only

后端 未结 2 1921
灰色年华
灰色年华 2020-12-01 01:49

I have problem when trying to parse with minimum value to map in Android.

There some sample JSON format with more information ex:

[{id:\"1\", name:\"         


        
2条回答
  •  孤街浪徒
    2020-12-01 02:52

    My pseudocode example will be as follows:

    JSONArray jsonArray = "[{id:\"1\", name:\"sql\"},{id:\"2\",name:\"android\"},{id:\"3\",name:\"mvc\"}]";
    JSON newJson = new JSON();
    
    for (each json in jsonArray) {
        String id = json.get("id");
        String name = json.get("name");
    
        newJson.put(id, name);
    }
    
    return newJson;
    

提交回复
热议问题