I want to be able to read stream (from a socket) of json messages using Jackson (2).
There are ways to pass a Reader as the source, such as doing:
ObjectMapper mapper = new ObjectMapper();
MyObject obj = mapper.readValue(aReader, MyObject.class);
but that will block until the entire json message has arrived and I want to avoid that.
Is there a way to have a buffer to which I can keep adding bytes with the ability to ask if the buffer contains a full json representation of a specific class?
Something like:
JsonBuffer buffer = new JsonBuffer(MyObject.class);
...
buffer.add(readBytes);
if (buffer.hasObject()) {
MyObject obj = buffer.readObject();
}
Thanks.