jackson-core
jackson-core copied to clipboard
JsonReadFeature: Introduce missing features for JSON5 compatibility
The optional features in the JSON parser allow it be configured to almost be a fully-compatible parser for JSON5.
There's just a few missing features, documented here: https://stackoverflow.com/questions/68312227/can-the-jackson-parser-be-used-to-parse-json5
Summarised as:
- hexadecimal numbers
- trailing decimal points on numbers (added via #773)
- plus signs before numbers (added via #774)
- extra whitespace characters
I propose that additional Jackson features be added for each of these JSON5 features to allow Jackson to be used as a fully-compliant JSON5 parser.
(#612 was a similar but more specific request, though it seems that feature is already covered)
EDIT: Following work has been done:
- #773 adds
JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS
to allow trailing decimal points on numbers - #774: adds
JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS
to allow leading plus sign on numbers
Sounds reasonable, as long as these are opt-in features (or, possibly, one JSON5 feature), to be added in JsonReadFeature
and not defaults.
I probably won't have time to work on this in near future but as usual would be happy to help someone else has time for a PR or two!
So, thanks to @pjfanning 's work, 2 number related features needed here are implemented to go in 2.14!
Ok, so looks like we have 2 things missing:
- Hexadecimal numbers
- Extra whitespace
Of these, hex numbers might be relatively easy to add (esp. for blocking parsers). White space could be trickier to do efficiently but maybe not (esp. for "common" white space like tabs and other low-numeric code ones); also seems like less commonly needed feature.
If anyone is interested, filing a separate issue for, say, Hexadecimal number support; adding unit tests (failing, under .../failing/
) would be a way to get things started.
And probably new JsonReadFeature
to enable said support (but not yet implemented)
If this is something that you are interested in getting implemented.