Open ferozed opened 1 month ago
Hello @ferozed , relying on an external library for json parsing was intentionally avoided in this library. The predecessor library uses the JSON-Java project and it caused problems in multiple ways. Moreover, last time when I looked at jackson, I couldn't find any way to obtain the line number & character position from the original json source (which this library uses in its validation error reports).
If you need to map an external json model (either jackson or gson), I suggest, instead of re-parsing, just mapping from one object model to an other.
Actually, in 0.19.0-RC1
which was released today morning, this library does the same when mapping from snakeyaml model to JsonValue
, you can use it for reference. If you can keep the line number + character position info, like in this snakeyaml mapper function, then even better.
Your concern about re-parsing is definitely valid, better to avoid that.
I have a suggestion. The validator is using it's own object classes
JsonParser
andJsonValue
.The issue is that when a service needs to parse the payload for it's own needs, the parse will be done two times. Once by the service and once for the validator.
If we can use existing json parsers like
jackson
orGson
then we can parse it once and hand the parsed tree to the validator