@Test public void shouldMapArray() { final ArrayNode<IJsonNode> expected = new ArrayNode<IJsonNode>().add(new TextNode("field1")).add(new IntNode(1)); final Object[] input = new Object[] { "field1", 1 }; Assert.assertEquals(expected, this.mapper.map(input)); Assert.assertEquals(expected, this.mapper.map(input, null, CachingArrayNode.class)); Assert.assertEquals(expected, this.mapper.map(input, null, IArrayNode.class)); Assert.assertEquals(expected, this.mapper.map(input, null, ArrayNode.class)); Assert.assertEquals(expected, this.mapper.map(input, null, new TypeToken<ArrayNode<IJsonNode>>() { }.getType())); Assert.assertEquals(expected, this.mapper.map(input, null, new TypeToken<IArrayNode<IJsonNode>>() { }.getType())); Assert.assertEquals(expected, this.mapper.map(input, null, new TypeToken<IArrayNode<AbstractJsonNode>>() { }.getType())); Assert.assertSame(CachingArrayNode.class, this.mapper.getDefaultMappingType(Object[].class)); }
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; }