{title:'Reading Continuous Streams', updated:'9.0.0'}

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.Builder#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 session = JsonParser. create().unbuffered().build().createSession(); | Object pojo; | Reader reader; | | reader = new StringReader("{foo:'bar'}{baz:'qux'}"); | pojo = session.parse(reader, JsonMap. class); // {foo:'bar'} | pojo = session.parse(reader, JsonMap. class); // {baz:'qux'} | | reader = new StringReader("[123][456]"); | pojo = session.parse(reader, int[].class); // [123] | pojo = session.parse(reader, 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.Builder}
  - {@link oaj.json.JsonParser.Builder#validateEnd() validateEnd()}
- {@link oaj.uon.UonParser.Builder}
  - {@link oaj.uon.UonParser.Builder#validateEnd() validateEnd()}
- {@link oaj.parser.Parser.Builder}
  - {@link oaj.parser.Parser.Builder#autoCloseStreams() validateEnd()}

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.