Is there any documentation on the new non-blocking JSON parser in 2.9.0?

1,086 views
Skip to first unread message

Bwmat

unread,
Aug 15, 2017, 9:19:07 PM8/15/17
to jackson-user
I'm interested in https://github.com/FasterXML/jackson-core/issues/57 , is there any documentation/examples?

Thanks,
Matthew w.

Tatu Saloranta

unread,
Aug 20, 2017, 8:11:48 PM8/20/17
to jackson-user
I hope others have something, but for now examples from `jackson-core`
tests may have to suffice.
Or, anything that describes how `aalto-xml` non-blocking mode works
should be highly applicable.

In nutshell, the only differences are:

1. You must construct non-blocking parser with new method
`createNonBlockingByteArrayParser()` -- it does NOT take input source
2. To feed input, you call method `getNonBlockingInputFeeder()` of
non-blocking parser from step (1)
3. All reading is exactly using normal `JsonParser` methods, but
`nextToken()` will return `NOT_AVAILABLE` if there isn't enough input
for more tokens yet (but input source is not closed yet)
4. You should only feed more input:
(a) First time right after constructing parser (no input buffered)
(b) Once parser returns `NOT_AVAILABLE`, to indicate it has
consumed input fed so far
(c) After all input has been fed, and parser has consumed all
input, `endOfInput()` should be called to indicate end-of-input

I hope this helps,

-+ Tatu +-

ps. I hope to find time and inspiration to write blog post or two
about non-blocking parser; but I would be especially happy if someone
else writes one and sends a link -- I will link all articles from
jackson portal page
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-user...@googlegroups.com.
> To post to this group, send email to jackso...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Bwmat

unread,
Aug 21, 2017, 12:32:42 PM8/21/17
to jackson-user
Thanks, that helps.

I assume methods that may require multiple tokens, such as readValueAsTree(), won't work?

Tatu Saloranta

unread,
Aug 21, 2017, 6:46:01 PM8/21/17
to jackson-user
On Mon, Aug 21, 2017 at 9:32 AM, Bwmat <bwmat.r...@gmail.com> wrote:
Thanks, that helps.

I assume methods that may require multiple tokens, such as readValueAsTree(), won't work?

Correct, they will not reliably work -- if input happens to be available they will, but unless this can be guaranteed (... in which case non-blocking may not be valuable anyway) they should not be used.

-+ Tatu +-
 
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages