### Question:
JsonUtils { public static JsonNode toJson(Object obj) { if(obj==null) { return JsonNodeFactory.instance.nullNode(); } else if(obj instanceof Map) { return toJson( (Map)obj ); } else if(obj instanceof Collection) { return toJson( (Collection)obj); } else { return valueToJson(obj); } } private  JsonUtils(); static ObjectMapper getObjectMapper(); static JsonNode json(String s); static JsonNode json(String s, boolean systemPropertySubstitution); static JsonNode json(InputStream stream, boolean systemPropertySubstitution); static JsonNode json(InputStream stream); static JsonNode json(Reader reader); static JsonNode json(Reader reader, boolean systemPropertySubstitution); static Object valueFromJson(ValueNode node); static ValueNode valueToJson(Object value); static Object fromJson(JsonNode json); static JsonNode toJson(Object obj); static String prettyPrint(JsonNode node); static void prettyPrint(StringBuilder bld, JsonNode node); static String toJson(String[] strings); static JsonSchema loadSchema(String resourceName); static String jsonSchemaValidation(JsonSchema schema, JsonNode node); static int size(JsonNode node);  }### Answer:
@Test public void testToson() throws Exception { HashMap m=new HashMap(); m.put("v1","value1"); HashMap n; m.put("o",n=new HashMap()); List a=new ArrayList(); n.put("a",a); a.add(new Integer(1)); JsonNode node=JsonUtils.toJson(m); Assert.assertEquals("value1",node.get("v1").asText()); Assert.assertEquals(1,node.get("o").get("a").get(0).asInt()); }