0

So there's actson that allows non-blocking JSON parsing. Then there's Jackson, that can't do non-blocking but can do POJO binding (databind). Is there a library that binds these two together? The main goal is to be able to feed byte arrays into the parser (no multithreading) and get a POJO in return, and then to be able to serialize that POJO back into JSON. With no intermediate JsonNode trees in both cases.

7
  • How would it suppose to work? Aug 1, 2017 at 20:50
  • @Antoniossss as it would with a tree, just without one. It's perfectly possible, just needs to be implemented. Jackson guys are in the process of implementing it but I'm not sure it's ready yet. Aug 1, 2017 at 21:02
  • Im just saying that I dont understand what do you want to achieve. Aug 1, 2017 at 21:27
  • @Antoniossss Populating POJOs with data from JSON. In a streaming, non-blocking way. Streaming means it shouldn't expect full input JSON available immediately in-memory but should use pieces of input JSON without ever accumulating full input. Non-blocking means it shouldn't block on an input source, like an InputStream, to wait for more data, instead byte arrays are sometimes manually fed into the parser, at programmer's convenience, without multithreading. Aug 1, 2017 at 21:36
  • @EJP the only way to implement push here is non-blocking reading of input, so I guess it's the same thing Aug 1, 2017 at 22:13

1 Answer 1

2

For what it is worth, Jackson actually can now (with 2.9.0) do non-blocking parsing. API is similar to Aalto XML for XML, and I am guessing Actson as well.

Making POJO binding work does, however, require buffering of contents at this point (since feeding of input in non-blocking manner can not be yet done in this contexts): this can be done by using TokenBuffer helper class. Upcoming Spring 5 will likely contain functionality implemented this way.

2
  • Thanks for the info. For now I've rolled my own JSON to POJO deserialiser based on Actson without buffering. Aug 11, 2017 at 16:37
  • Interesting. I assume this is for specific use case (that is, code for specific pojo types, and not something generic)? Buffering is definitely not mandatory in general, but not doing that requires some work on input handling that is non-obvious (at least for general case). However it is quite doable when code fully knows what to build.
    – StaxMan
    Aug 11, 2017 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.