Reading Continuous Streams

The following parsers can be configured to read continuous streams of objects from the same input stream:

- {@link oaj.json.JsonParser}
- {@link oaj.uon.UonParser}
- {@link oaj.msgpack.MsgPackParser}

The {@link oaj.json.JsonParser} and {@link oaj.uon.UonParser} classes can read continuous streams by using the {@link oaj.parser.Parser#PARSER_unbuffered PARSER_unbuffered} setting. This prevents the parsers from using an internal buffer that would read past the end of the currently parsed POJO.

##### Examples:

// If you're calling parse on the same input multiple times, use a session instead of the parser directly. ReaderParserSession p = JsonParser.create().unbuffered().build().createSession(); Object x; Reader r; r = new StringReader("{foo:'bar'}{baz:'qux'}"); x = p.parse(r, ObjectMap.class); // {foo:'bar'} x = p.parse(r, ObjectMap.class); // {baz:'qux'} r = reader("[123][456]"); x = p.parse(r, int[].class); // [123] x = p.parse(r, int[].class); // [456]

Note that this isn't perfect in all cases since you can't combine two JSON numbers into a single reader (e.g. "123" + "456" = "123456").

For obvious reasons, do not use the following properties when reading continuous streams:

- {@link oaj.json.JsonParser#JSON_validateEnd}
- {@link oaj.uon.UonParser#UON_validateEnd}
- {@link oaj.parser.Parser#PARSER_autoCloseStreams}

The {@link oaj.msgpack.MsgPackParser} class doesn't use any internal buffering to begin with, so it can be used with continuous streams without any special properties.