Class JsonStreamParser

java.lang.Object
com.couchbase.client.core.json.stream.JsonStreamParser
All Implemented Interfaces:
Closeable, AutoCloseable

public class JsonStreamParser extends Object implements Closeable
Create an instance with builder(). Use the builder to register JSON pointers and associated callbacks.

Supply the input JSON by calling feed(ByteBuf) repeatedly. Close the parser after feeding the last of the data.

Not thread safe.

  • Method Details

    • builder

      public static JsonStreamParser.Builder builder()
      Construct new parser instances using the builder returned by this method.
    • feed

      public void feed(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf input) throws DecodingFailureException
      Consumes all readable bytes from the given buffer. Searches for values matching the configured JSON pointers and invokes callbacks for any matches.

      Call this method repeatedly as more input becomes available.

      Throws:
      DecodingFailureException - if malformed JSON is detected in this chunk of input or if a value consumer throws an exception.
    • endOfInput

      public void endOfInput()
      Should be called after last chunk of data to parse has been fed. After calling this method no more data can be fed and parser assumes no more data will be available.
      Throws:
      DecodingFailureException - if malformed JSON is detected in this chunk of input.
    • close

      public void close()
      Releases resources managed by the parser.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable