My question is very similiar to this: Unable to parse Json array using Gson
But I cann\'t get the answer from it. The answer from above link:
public
You can use this method in order to parse generic json string to map
public Map getMapFromJson(String jsonString) {
Map map = new HashMap<>();
try {
JSONObject object = new JSONObject(jsonString);
Iterator> iterator = object.keys();
while (iterator.hasNext()) {
String key = (String) iterator.next();
if(!key.isEmpty() && !object.getString(key).isEmpty()){
map.put(key, object.getString(key));
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return map;
}