「Java開発」Json配列からMapに変換する方法

Javaコード
public static Map<String, Object> getMap(String jsonString)
{
JSONObject jsonObject;
try
{
jsonObject = new JSONObject(jsonString);
@SuppressWarnings(“unchecked")
Iterator<String> keyIter = jsonObject.keys();
String key;
Object value;
Map<String, Object> valueMap = new HashMap<String, Object>();
while (keyIter.hasNext())
{
key = (String) keyIter.next();
value = jsonObject.get(key);
valueMap.put(key, value);
}
return valueMap;
}
catch (JSONException e)
{
e.printStackTrace();
}
return null;
}

Java

Posted by arkgame