@Test public void shouldNestedMapObject() { final Map<String, Object> object = new HashMap<String, Object>(); object.put("a", 1); object.put("b", "test"); final Map<String, Object> nested = new HashMap<String, Object>(); nested.put("1", "x"); nested.put("2", true); object.put("nestedObject", nested); final IJsonNode node = this.mapper.map(object); final ObjectNode expected = new ObjectNode(); expected.put("a", IntNode.valueOf(1)); expected.put("b", TextNode.valueOf("test")); final ObjectNode nestedObjectNode = new ObjectNode(); nestedObjectNode.put("1", TextNode.valueOf("x")); nestedObjectNode.put("2", BooleanNode.valueOf(true)); expected.put("nestedObject", nestedObjectNode); Assert.assertEquals(expected, node); }
public IJsonNode map(final Object value) { if (value == null) return NullNode.getInstance(); final Type type = this.getDefaultMappingType(value.getClass()); if (type == null) throw new IllegalArgumentException("Cannot find appropriate json type for " + value); return this.map(value, null, type); }
JavaToJsonMapper extends AbstractTypeMapper<TypeMapper<?, ?>> { public IJsonNode map(final Object value) { if (value == null) return NullNode.getInstance(); final Type type = this.getDefaultMappingType(value.getClass()); if (type == null) throw new IllegalArgumentException("Cannot find appropriate json type for " + value); return this.map(value, null, type); } }
JavaToJsonMapper extends AbstractTypeMapper<TypeMapper<?, ?>> { public IJsonNode map(final Object value) { if (value == null) return NullNode.getInstance(); final Type type = this.getDefaultMappingType(value.getClass()); if (type == null) throw new IllegalArgumentException("Cannot find appropriate json type for " + value); return this.map(value, null, type); } protected  JavaToJsonMapper(); }
JavaToJsonMapper extends AbstractTypeMapper<TypeMapper<?, ?>> { public IJsonNode map(final Object value) { if (value == null) return NullNode.getInstance(); final Type type = this.getDefaultMappingType(value.getClass()); if (type == null) throw new IllegalArgumentException("Cannot find appropriate json type for " + value); return this.map(value, null, type); } protected  JavaToJsonMapper(); @SuppressWarnings("unchecked") TypeMapper<F, T> getMapper(final Class<?> fromClass, final Class<T> targetType); IJsonNode map(final Object value); @SuppressWarnings("unchecked") T map(final Object from, final T to, final Type targetType); }
JavaToJsonMapper extends AbstractTypeMapper<TypeMapper<?, ?>> { public IJsonNode map(final Object value) { if (value == null) return NullNode.getInstance(); final Type type = this.getDefaultMappingType(value.getClass()); if (type == null) throw new IllegalArgumentException("Cannot find appropriate json type for " + value); return this.map(value, null, type); } protected  JavaToJsonMapper(); @SuppressWarnings("unchecked") TypeMapper<F, T> getMapper(final Class<?> fromClass, final Class<T> targetType); IJsonNode map(final Object value); @SuppressWarnings("unchecked") T map(final Object from, final T to, final Type targetType); static final JavaToJsonMapper INSTANCE; }