Class JsonTranscoder

    • Constructor Detail

      • JsonTranscoder

        public JsonTranscoder()
    • Method Detail

      • doDecode

        protected JsonDocument doDecode​(String id,
                                        com.couchbase.client.deps.io.netty.buffer.ByteBuf content,
                                        long cas,
                                        int expiry,
                                        int flags,
                                        ResponseStatus status)
                                 throws Exception
        Description copied from class: AbstractTranscoder
        Perform the decoding of the received response.
        Specified by:
        doDecode in class AbstractTranscoder<JsonDocument,​JsonObject>
        Parameters:
        id - the id of the document.
        content - the encoded content of the document.
        cas - the cas value of the document.
        expiry - the expiration time of the document.
        flags - the flags set on the document.
        status - the response status.
        Returns:
        the decoded document.
        Throws:
        Exception - if something goes wrong during the decode process.
      • jsonObjectToByteBuf

        public com.couchbase.client.deps.io.netty.buffer.ByteBuf jsonObjectToByteBuf​(JsonObject input)
                                                                              throws Exception
        Throws:
        Exception
      • byteBufToJsonObject

        public JsonObject byteBufToJsonObject​(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)
                                       throws Exception
        Converts a ByteBuf to a JsonObject, without releasing the buffer
        Parameters:
        input - the buffer to convert. It won't be cleared (contrary to classical decode)
        Returns:
        a JsonObject decoded from the buffer
        Throws:
        Exception
      • byteBufJsonValueToObject

        public Object byteBufJsonValueToObject​(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)
                                        throws Exception
        Converts a ByteBuf representing a valid JSON entity to a generic Object, without releasing the buffer. The entity can either be a JSON object, array or scalar value, potentially with leading whitespace (which gets ignored). Detection of JSON objects and arrays is attempted in order not to incur an additional conversion step (JSON to Map to JsonObject for example), but if a Map or List is produced, it will be transformed to JsonObject or JsonArray (with a warning logged).
        Parameters:
        input - the buffer to convert. It won't be cleared (contrary to classical decode)
        Returns:
        a Object decoded from the buffer
        Throws:
        Exception