{ "locations": [{ "_id": null, "coords": {}, "name": null, "placeType": null }] } How to add a value to the placeType parameter using a HashMap looking at this json?
{ "locations": [{ "_id": null, "coords": {}, "name": null, "placeType": null }] } How to add a value to the placeType parameter using a HashMap looking at this json?
Try to transfer Json to HashMap , and then without any problems add values to the map.
public Map<String, Object> toMap(JSONObject object) throws JSONException { Map<String, Object> map = new HashMap<String, Object>(); Iterator<String> keysItr = object.keys(); while(keysItr.hasNext()) { String key = keysItr.next(); Object value = object.get(key); if(value instanceof JSONObject) { value = toMap((JSONObject) value); } map.put(key, value); } return map; } Source: https://ru.stackoverflow.com/questions/617233/
All Articles