Reputation: 1191
I would like to take advantage of the JsonParser API class of the Jackson library. However, it is quite tedious for me to build a json string builder. So I made use of a Map to contain the values for my Json object.
Map<String,Object> myMainMap = new HashMap<String,Object>();
Map<String,String> myMap = new HashMap<String,String>();
myMap.put("node1","value1");
myMap.put("node2","value2");
myMainMap.put("rootNode",myMap);
How do I convert this Map into a org.codehaus.jackson.JsonParser so that I can take advantage of the methods available for this API?
Upvotes: 0
Views: 3444
Reputation: 3660
ObjectMapper mapper = new ObjectMapper();
System.out.println(mapper.writeValueAsString(myMap) );
Upvotes: 3