Json5 Support and Deserializer Improvements
Fully compliant with JSON5
I think the JSON5 informative example says it best:
{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',],
"backwardsCompatible": "with JSON",
}
JSON5 offers a number of extremely helpful, user-focused constructions, and describes a BNF that's shockingly close to how Jankson is already structured. Both parsing and serialization were given the small tweaks they needed to bring them into line, and compliance has been added to the test suite to make sure we keep this promise going forward: Jankson does JSON5.
Advanced deserialization
In its 1.0 release, Jankson's deserializer - the part that turns a JsonObject into a plain java object of your design - lagged pretty significantly behind other json frameworks, requiring for instance Jankson and Gson to be used together. Jankson still supports this usage pattern going forward, but the deserializer has received some important upgrades:
- All JavaSE-provided collections should deserialize correctly.
- Jankson can now unpack most nested custom types without a type adapter
- Most generics - as long as they're not type parameters of the top-level object you pass to
fromJson
- are recovered at runtime and used to make better choices about what objects to create and how to unpack them.
Some limitations still remain:
- Nested generics like
List<List<T>>
still fail to unpack. Future support is planned, but if you need this behavior right now, it's reccommended to use the Jankson+Gson pattern.