I am using the Streaming API of the JsonParser Jackson to do custom json analysis in java.
Is there a way to achieve functionality similar to the method peek()where the next token is returned, but the cursor position does not move forward?
The use case for this is similar to the following:
JsonParser parser = new JsonFactory().createParser(inputStream);
while(parser.peek() != JsonToken.START_ARRAY){
...do something with the current token...
}
The code examples I've seen for Jackson use the method nextToken()for the above case, which, unfortunately, also moves the cursor forward in the stream.
Is it possible peek()with Jackson out of the box or perhaps achievable using an additional method?
NB. are not interested in other libraries, therefore no library " x does all this and the kitchen sink " does not respond.
source
share