Skip to content

Commit

Permalink
Merge branch '2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 26, 2016
2 parents a0bd159 + c3e0113 commit 52c9ffc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Expand Up @@ -82,7 +82,7 @@ public StringWrapper(String value) {
}

protected static class ObjectWrapper {
private final Object object;
final Object object;
protected ObjectWrapper(final Object object) {
this.object = object;
}
Expand Down
Expand Up @@ -96,20 +96,24 @@ public Map<String,Object> deserialize(JsonParser p, DeserializationContext ctxt)
}
}

static class Untyped989 {
static class DelegatingUntyped {
protected Object value;

@JsonCreator // delegating
public Untyped989(Object v) {
public DelegatingUntyped(Object v) {
value = v;
}
}

static class WrappedUntyped {
static class WrappedPolymorphicUntyped {
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS)
public Object value;
}

static class WrappedUntyped1460 {
public Object value;
}

/*
/**********************************************************
/* Test methods
Expand Down Expand Up @@ -272,11 +276,11 @@ public void testNonVanilla() throws IOException
assertTrue(l.get(0) instanceof Map<?,?>);
assertTrue(l.get(1) instanceof List<?>);

ObjectReader rDefault = mapper.readerFor(WrappedUntyped.class);
ObjectReader rDefault = mapper.readerFor(WrappedPolymorphicUntyped.class);
ObjectReader rAlt = rDefault
.with(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS,
DeserializationFeature.USE_BIG_INTEGER_FOR_INTS);
WrappedUntyped w;
WrappedPolymorphicUntyped w;

w = rDefault.readValue(aposToQuotes("{'value':10}"));
assertEquals(Integer.valueOf(10), w.value);
Expand Down Expand Up @@ -340,8 +344,8 @@ public void testUntypedWithMapDeser() throws IOException

public void testNestedUntyped989() throws IOException
{
Untyped989 pojo;
ObjectReader r = MAPPER.readerFor(Untyped989.class);
DelegatingUntyped pojo;
ObjectReader r = MAPPER.readerFor(DelegatingUntyped.class);

pojo = r.readValue("[]");
assertTrue(pojo.value instanceof List);
Expand All @@ -365,4 +369,17 @@ public void testUntypedWithJsonArrays() throws Exception
ob = MAPPER.readValue("[1]", Object.class);
assertEquals(Object[].class, ob.getClass());
}

public void testUntypedIntAsLong() throws Exception
{
final String JSON = aposToQuotes("{'value':3}");
WrappedUntyped1460 w = MAPPER.readerFor(WrappedUntyped1460.class)
.readValue(JSON);
assertEquals(Integer.valueOf(3), w.value);

w = MAPPER.readerFor(WrappedUntyped1460.class)
.with(DeserializationFeature.USE_LONG_FOR_INTS)
.readValue(JSON);
assertEquals(Long.valueOf(3), w.value);
}
}

0 comments on commit 52c9ffc

Please sign in to comment.