Skip to content

Commit

Permalink
Fix #63
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 24, 2019
1 parent 14aa5f5 commit 8a8679a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ public enum Feature
*
* @since 2.8 (enabled by default since 2.10)
*/
USE_FIELDS(false, true),

USE_FIELDS(true, true),
;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public Object readNext(JSONReader r, JsonParser p) throws IOException {
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
throw JSONObjectException.from(p, "Unexpected token "+p.getCurrentToken()+"; should get START_ARRAY");
throw JSONObjectException.from(p, "Unexpected token %s; should get START_ARRAY",
p.getCurrentToken());
}

CollectionBuilder b = r._collectionBuilder(null);
Expand Down Expand Up @@ -60,4 +61,4 @@ public Object read(JSONReader r, JsonParser p) throws IOException {
} while (p.nextToken() != JsonToken.END_ARRAY);
return b.buildArray(_elementType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected ValueReader collectionReader(Class<?> collectionType, ResolvedType val
List<ResolvedType> params = valueType.typeParametersFor(Map.class);
valueReader = mapReader(rawValueType, params.get(1));
} else {
valueReader = createReader(null, rawValueType, rawValueType);
valueReader = findReader(rawValueType);
}
return new CollectionReader(collectionType, valueReader);
}
Expand All @@ -195,7 +195,7 @@ protected ValueReader mapReader(Class<?> mapType, ResolvedType valueType)
List<ResolvedType> params = valueType.typeParametersFor(Map.class);
valueReader = mapReader(rawValueType, params.get(1));
} else {
valueReader = createReader(null, rawValueType, rawValueType);
valueReader = findReader(rawValueType);
}
return new MapReader(mapType, valueReader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ protected XY() { }
public void setY(int value) { y = value; }
}

public void testDefaulSettings() {
assertFalse(JSON.std.isEnabled(JSON.Feature.USE_FIELDS));
public void testDefaultSettings() {
// Changed in 2.10
assertTrue(JSON.std.isEnabled(JSON.Feature.USE_FIELDS));
}

public void testSerializeWithoutField() throws Exception
{
String json = JSON.std.without(JSON.Feature.USE_FIELDS)
.asString(new XY(1, 2));
assertEquals(aposToQuotes("{'y':2}"), json);
}

public void testSerializeWithField() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public byte[] getStuff() {
}

static class BeanBase {
public int _value;
int _value;

public int getValue() { return _value; }
public void setValue(int v) { _value = v; }
}

static class BaseImpl extends BeanBase {
public int _extra;
int _extra;

protected BaseImpl() { }
public BaseImpl(int v, int x) {
Expand Down
2 changes: 1 addition & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Project: jackson-jr

2.10.0 (not yet released)

No changes since 2.9
#63: Change default for `JSON.Feature.USE_FIELDS` to `true` (from false) in 2.10

2.9.9 (not yet released)

Expand Down

0 comments on commit 8a8679a

Please sign in to comment.