JSON
Convert JSON String to Java Map
import org.json.JSONObject;
import org.json.simple.JSONValue;
//........
public static HashMap<String, Object> jsonStringToMap(
String jsonString) throws JSONException {
HashMap<String, Object> map = new HashMap<String, Object>();
try {
JSONObject jObject = new JSONObject(jsonString);
Iterator<?> keys = jObject.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
String value = jObject.getString(key);
map.put(key, value);
}
} catch (Exception e) {
}
return map;
}
Post a Comment
0 Comments