Json { public static Object toObject(JsonNode node) { return toPojo(node, Object.class); }  static JsonNode get(JsonNode json, String fieldPath); static Object get(JsonNode json, String fieldPath, Object defaultValue); static JsonNode set(JsonNode json, String fieldPath, Object value); static JsonNode with(JsonNode json, String fieldPath, Object value); static ArrayNode withArray(JsonNode json, String fieldPath); static ObjectNode withObject(JsonNode json, String fieldPath); static JsonNode remove(JsonNode json, String fieldPath); static void removeFromSet(ArrayNode set, Object... values); static void addToSet(ArrayNode set, Object... values); static JsonMerger merger(); static boolean isJson(String string); static boolean isObject(String string); static boolean isNull(JsonNode value); static boolean isNullOrEmpty(JsonNode node); static ObjectMapper mapper(); @SuppressWarnings("unchecked") static Map<String, Object> readMap(String json); static JsonNode readNode(String json); static JsonNode readNode(byte[] json); static JsonNode readNode(URL url); static ObjectNode readObject(String json); static ArrayNode readArray(String json); static Builder builder(); static ObjectNode object(); static ObjectNode object(Object... fields); static ObjectNode addAll(ObjectNode object, Object... fields); static ArrayNode array(); static ArrayNode array(Object... values); static ArrayNode addAll(ArrayNode array, Object... values); @SuppressWarnings({ "rawtypes", "unchecked" }) static JsonAssert<K> assertNode(K node); static boolean isObject(JsonNode node); static ObjectNode checkObject(JsonNode node); static boolean isArray(JsonNode node); static ArrayNode checkArray(JsonNode node); static Optional<JsonNode> checkObject(JsonNode input, String propertyPath, boolean required); static String checkStringNotNullOrEmpty(JsonNode input, String propertyPath); static Optional<String> checkString(JsonNode input, String path); static Optional<JsonNode> checkStringNode(JsonNode input, String propertyPath, boolean required); static String checkString(JsonNode node); static Boolean checkBoolean(JsonNode node); static Double checkDouble(JsonNode node); static JsonNode checkNotNull(JsonNode node); static ObjectNode toObjectNode(Object object); static ArrayNode toArrayNode(Object object); static JsonNode toJsonNode(Object object); static Object toObject(JsonNode node); static K toPojo(JsonNode jsonNode, Class<K> pojoClass); static K toPojo(JsonNode node, JavaType type); static K toPojo(String json, Class<K> pojoClass); static K toPojo(String json, JavaType pojoType); static K toPojo(String json, TypeReference<K> typeRef); static K toPojo(byte[] jsonBytes, Class<K> pojoClass); static K toPojo(JsonNode jsonNode, String fieldPath, Class<K> pojoClass); static K updatePojo(String json, K pojo); static K updatePojo(byte[] json, K pojo); static ArrayNode withArray(ObjectNode node, String path); static ObjectNode withObject(ObjectNode node, String path); static String toString(Object object); static String toString(Object object, boolean pretty); static JsonNode fullReplaceTextualFields(JsonNode node, String fieldName, String value); static JsonNode removeDeeply(JsonNode node, String fieldName); static final String EMPTY_OBJECT; }
@Test public void testToObject() { assertEquals(1, Json.toObject(Json.toJsonNode(1))); assertEquals("test", Json.toObject(Json.toJsonNode("test"))); assertEquals(true, Json.toObject(Json.toJsonNode(true))); }