jakartaee / jsonp-api

Jakarta JSON Processing
https://eclipse.org/ee4j/jsonp
Other
141 stars 61 forks source link

support retrieval of the event for the current parsing state in JsonParser #233

Closed emattheis closed 3 years ago

emattheis commented 4 years ago

I'm interested in using JSON-P and JSON-P together in order to efficiently process large JSON data sets while retaining the convenience of POJO mapping. I've raised an issue with the JSON-B API to that end, but one of the sticking points is the ability to properly position a JsonParser for use by JSON-B. It would be convenient if JsonParser had a peek() method that could return the next event without consuming it.

emattheis commented 4 years ago

After thinking about this more carefully, it seems that providing access to the current event is likely much more efficient than trying to provide lookahead support. For the use case I'm interested in, a JsonParser instance could be advanced to the correct location and then passed to a Jsonb instance to deserialize a mapped POJO but the Jsonb needs to be aware of the current event, otherwise it must call next() which means the caller has to advance the stream only to the position directly before the correct location. This forces the caller to make assumptions about the future state of the stream and depend on error handling to recover if those assumptions don't hold.

lukasj commented 3 years ago

I believe this is covered by #282