@Test public void testFromJson() throws Exception { JsonNode node=JsonUtils.json(getClass().getResourceAsStream("/JsonNodeDocTest-complex.json")); Map obj=(Map)JsonUtils.fromJson(node); Assert.assertTrue(obj.get("object1") instanceof Map); Assert.assertTrue(obj.get("object2") instanceof Map); Assert.assertEquals("value3",((Map)obj.get("object2")).get("simple3")); Assert.assertEquals(2,((List) ((Map)obj.get("object1")).get("array1")).size()); Assert.assertEquals("value1",((Map)((List)((Map)obj.get("object1")).get("array1")).get(0)).get("simple1")); }
public static Object fromJson(JsonNode json) { if(json==null||json instanceof NullNode) { return null; } else if(json instanceof ObjectNode) { return fromJson((ObjectNode)json); } else if(json instanceof ArrayNode) { return fromJson((ArrayNode)json); } else { return valueFromJson( (ValueNode)json); } }
JsonUtils { public static Object fromJson(JsonNode json) { if(json==null||json instanceof NullNode) { return null; } else if(json instanceof ObjectNode) { return fromJson((ObjectNode)json); } else if(json instanceof ArrayNode) { return fromJson((ArrayNode)json); } else { return valueFromJson( (ValueNode)json); } } }
JsonUtils { public static Object fromJson(JsonNode json) { if(json==null||json instanceof NullNode) { return null; } else if(json instanceof ObjectNode) { return fromJson((ObjectNode)json); } else if(json instanceof ArrayNode) { return fromJson((ArrayNode)json); } else { return valueFromJson( (ValueNode)json); } } private  JsonUtils(); }
JsonUtils { public static Object fromJson(JsonNode json) { if(json==null||json instanceof NullNode) { return null; } else if(json instanceof ObjectNode) { return fromJson((ObjectNode)json); } else if(json instanceof ArrayNode) { return fromJson((ArrayNode)json); } else { return valueFromJson( (ValueNode)json); } } 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); }
JsonUtils { public static Object fromJson(JsonNode json) { if(json==null||json instanceof NullNode) { return null; } else if(json instanceof ObjectNode) { return fromJson((ObjectNode)json); } else if(json instanceof ArrayNode) { return fromJson((ArrayNode)json); } else { return valueFromJson( (ValueNode)json); } } 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);  }