Add peekToken()
, mostly to support non-blocking parsing
#375
Labels
3.x
Issues to be only tackled for Jackson 3.x, not 2.x
With upcoming support for non-blocking parsing (see #57 for json, but also for other formats) there may be need to add more methods to help with some specific aspects.
One such aspect is that due to input handling there is no way to properly implement "lazy" decoding for most events: since intent to skip is not known early enough,
nextToken()
must buffer all content.This is fine in many cases (start/end markers, small numbers, property names that must be retained), but can be sub-optimal for larger values (binary, long text).
Now, adding something like
skipToken()
might work, but assumes that type of next token is fully known from context; this may or may not be known.But it should be possible to add a new variant of
nextToken()
; one that does advance input enough to detect type of token, but without requiring anything more than peeking one byte (or couple, retaining them). This method specifically should not advance logical token stream so that:peekToken()
?) multiple times and get same result (that is: it's idempotent)nextToken()
, returned type must be same as whatpeekToken()
returnedNow: although this method mostly makes sense for non-blocking use case, it might be useful for blocking I/O too, so let's expect support to be added there too, over time.
And since this is new addition operation has to be optional: that is, initial default implementation should return
JsonToken.NOT_AVAILABLE
(alternative would be throwing an exception).The text was updated successfully, but these errors were encountered: