JSON STRING到HASHMAP JSON SIMPLE

时间:2013-10-18 19:04:05

标签: java json

我有一个 JSONString

<i>{1={"id":"1","description":"Red","Objects":{"doors":4,"number":4},"life":100}}</i>

如何将此JSONString放入带有JSONSimple的哈希映射?

1 个答案:

答案 0 :(得分:0)

此代码用于JSON-simple的wiki页面http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_1_-_Convenient_way:_Use_JSONValue

String s="[{1={"id":"1","description":"Red","Objects":   {"doors":4,"number":4},"life":100}}]";
Object obj=JSONValue.parse(s);
JSONArray array=(JSONArray)obj;