Convert json string to Java Map(JSONLib)

Viewed 26975

How can I convert json string to Java Map using JSON-lib(http://json-lib.sourceforge.net/) ? I can convert to DynaBean:

JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON( str );  
DynaBean bean = (DynaBean) JSONSerializer.toJava( jsonObject );  

but I have not found a method to convert directly to Java Map

Edit:

I have found the solution:

JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON( str );
Map<String, Object> myMap = (Map<String, Object>) JSONObject.toBean(jsonObject, Map.class)
1 Answers
Related