Interface JSONB


public interface JSONB
This is the main entry point for using fastjson2 binary format (JSONB) API. JSONB is a high-performance binary serialization format that is more compact and faster than JSON text format.

JSONB binary format specification:

 x90          # type_char int
 x91          # binary len_int32 bytes
 x92          # type [str] symbol_int32 jsonb
 x93          # reference

 x94 - xa3    # array_0 - array_15
 xa4          # array len_int32 item*

 xa5          # object_end
 xa6          # object_start

 xa7          # local time b0 b1 b2
 xa8          # local datetime b0 b1 b2 b3 b4 b5 b6
 xa9          # local date b0 b1 b2 b3
 xab          # timestamp millis b0 b1 b2 b3 b4 b5 b6 b7
 xac          # timestamp seconds b0 b1 b2 b3
 xad          # timestamp minutes b0 b1 b2 b3
 xae          # timestamp b0 b1 b2 b3 b4 b5 b6 b7 nano_int32

 xaf          # null
 xb0          # boolean false
 xb1          # boolean true
 xb2          # double 0
 xb3          # double 1
 xb4          # double_long
 xb5          # double
 xb6          # float_int
 xb7          # float
 xb8          # decimal_long
 xb9          # decimal
 xba          # bigint_long
 xbb          # bigint
 xbc          # short
 xbd          # byte
 xbe          # long
 xbf          # long encoded as 32-bit int
 xc0 - xc7    # three-octet compact long (-x40000 to x3ffff)
 xc8 - xd7    # two-octet compact long (-x800 to x7ff, xd0 is 0)
 xd8 - xef    # one-octet compact long (-x8 to xf, e0 is 0)

 xf0 - xff    # one-octet compact int
 x00 - x2f    # one-octet compact int

 x30 - x3f    # two-octet compact int (-x800 to x7ff)
 x40 - x47    # three-octet compact int (-x40000 to x3ffff)
 x48          # 32-bit signed integer ('I')

 x49 - x78    # ascii string length 0-47
 x79          # ascii-8 string variable-length
 x7a          # utf-8 string variable-length
 x7b          # utf-16 string variable-length
 x7c          # utf-16LE string variable-length
 x7d          # utf-16BE string variable-length
 x7e          # gb18030 string variable-length
 x7f          # symbol
 

Example usage:

 // 1. Convert object to JSONB bytes
 User user = new User(1L, "John", 30);
 byte[] jsonbBytes = JSONB.toBytes(user);

 // 2. Parse JSONB bytes to object
 User parsedUser = JSONB.parseObject(jsonbBytes, User.class);

 // 3. Convert primitive values to JSONB bytes
 byte[] intBytes = JSONB.toBytes(123);
 byte[] strBytes = JSONB.toBytes("Hello World");
 byte[] boolBytes = JSONB.toBytes(true);

 // 4. Parse JSONB bytes with features
 User user = JSONB.parseObject(jsonbBytes, User.class, JSONReader.Feature.FieldBased);

 // 5. Convert JSONB bytes to JSON string for debugging
 String jsonString = JSONB.toJSONString(jsonbBytes);

 // 6. Parse JSONB bytes to JSONObject
 JSONObject jsonObject = JSONB.parseObject(jsonbBytes);

 // 7. Parse JSONB bytes to JSONArray
 JSONArray jsonArray = JSONB.parseArray(jsonbBytes);

 // 8. Parse JSONB bytes to List
 List<User> userList = JSONB.parseArray(jsonbBytes, User.class);
 
Since:
2.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Constants for JSONB binary format specification
    static interface 
    IO utility methods for JSONB serialization
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <T> T
    copy(T object, JSONWriter.Feature... features)
    Creates a deep copy of the specified object
    static void
    dump(byte[] jsonbBytes)
    Dumps the JSONB bytes to standard output for debugging purposes
    static void
    dump(byte[] jsonbBytes, SymbolTable symbolTable)
    Dumps the JSONB bytes to standard output for debugging purposes with a symbol table
    static byte[]
    fromJSONBytes(byte[] jsonUtf8Bytes)
    Converts JSON bytes to JSONB bytes
    static byte[]
    Converts a JSON string to JSONB bytes
    static boolean
    isInt32(int type)
    Checks if the specified type is an int32 type
    static boolean
    isInt32Byte(int type)
    Checks if the specified type is an int32 byte type
    static boolean
    Checks if the specified integer value can be represented as an int32 byte value
    static boolean
    Checks if the specified integer value is within the int32 byte value range
    static boolean
    isInt32Num(int type)
    Checks if the specified type is an int32 number type
    static boolean
    isInt32Short(int type)
    Checks if the specified type is an int32 short type
    static boolean
    isInt64Byte(int type)
    Checks if the specified type is an int64 byte type
    static boolean
    isInt64Num(int type)
    Checks if the specified type is an int64 number type
    static boolean
    isInt64Short(int type)
    Checks if the specified type is an int64 short type
    static Object
    parse(byte[] jsonbBytes, JSONReader.Context context)
    Parses JSONB bytes to an object using the specified context
    static Object
    parse(byte[] jsonbBytes, JSONReader.Feature... features)
    Parses JSONB bytes to an object with specified features
    static Object
    parse(byte[] jsonbBytes, SymbolTable symbolTable, JSONReader.Feature... features)
    Parses JSONB bytes to an object with a symbol table and features
    static Object
    Parses JSONB from an input stream to an object using the specified context
    static JSONArray
    parseArray(byte[] jsonbBytes)
    Parses JSONB bytes to a JSONArray
    static <T> List<T>
    parseArray(byte[] jsonbBytes, Type type)
    Parses JSONB bytes to a list of objects of the specified type
    static <T> List<T>
    parseArray(byte[] jsonbBytes, Type... types)
    Parses JSONB bytes to a list of objects with specified types
    static <T> List<T>
    parseArray(byte[] jsonbBytes, Type[] types, JSONReader.Feature... features)
    Parses JSONB bytes to a list of objects with specified types and features
    static <T> List<T>
    parseArray(byte[] jsonbBytes, Type type, JSONReader.Feature... features)
    Parses JSONB bytes to a list of objects of the specified type with features
    static JSONArray
    Parses JSONB from an input stream to a JSONArray using the specified context
    static JSONObject
    parseObject(byte[] jsonbBytes)
    Parses JSONB bytes to a JSONObject
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass)
    Parses JSONB bytes with offset and length to an object of the specified class
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, JSONReader.Feature... features)
    Parses JSONB bytes with offset and length to an object of the specified class with features
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, SymbolTable symbolTable)
    Parses JSONB bytes with offset and length to an object of the specified class with a symbol table
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, SymbolTable symbolTable, JSONReader.Feature... features)
    Parses JSONB bytes with offset and length to an object of the specified class with a symbol table and features
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Type type)
    Parses JSONB bytes with offset and length to an object of the specified type
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Type objectType, JSONReader.Context context)
    Parses JSONB bytes with offset and length to an object of the specified type using the specified context
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Type objectType, JSONReader.Feature... features)
    Parses JSONB bytes with offset and length to an object of the specified type with features
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Type objectClass, SymbolTable symbolTable)
    Parses JSONB bytes with offset and length to an object of the specified type with a symbol table
    static <T> T
    parseObject(byte[] jsonbBytes, int off, int len, Type objectClass, SymbolTable symbolTable, JSONReader.Feature... features)
    Parses JSONB bytes with offset and length to an object of the specified type with a symbol table and features
    static JSONObject
    parseObject(byte[] jsonbBytes, JSONReader.Feature... features)
    Parses JSONB bytes to a JSONObject with specified features
    static <T> T
    parseObject(byte[] jsonbBytes, TypeReference typeReference, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified type reference
    static <T> T
    parseObject(byte[] jsonbBytes, Class<T> objectClass)
    Parses JSONB bytes to an object of the specified class
    static <T> T
    parseObject(byte[] jsonbBytes, Class<T> objectClass, Filter filter, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified class with a filter and features
    static <T> T
    parseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Context context)
    Parses JSONB bytes to an object of the specified class using the specified context
    static <T> T
    parseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified class with features
    static <T> T
    parseObject(byte[] jsonbBytes, Type objectType)
    Parses JSONB bytes to an object of the specified type
    static <T> T
    parseObject(byte[] jsonbBytes, Type... types)
    Parses JSONB bytes to an object with specified types
    static <T> T
    parseObject(byte[] jsonbBytes, Type objectClass, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified type with features
    static <T> T
    parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable)
    Parses JSONB bytes to an object of the specified type with a symbol table
    static <T> T
    parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable, Filter[] filters, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified type with a symbol table, filters and features
    static <T> T
    parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable, JSONReader.Feature... features)
    Parses JSONB bytes to an object of the specified type with a symbol table and features
    static <T> T
    parseObject(InputStream in, int length, Type objectType, JSONReader.Context context)
    Parses JSONB from an input stream with specified length to an object of the specified type using the specified context
    static <T> T
    parseObject(InputStream in, int length, Type objectType, JSONReader.Feature... features)
    Parses JSONB from an input stream with specified length to an object of the specified type with features
    static JSONObject
    Parses JSONB bytes to a JSONObject using the specified context
    static <T> T
    parseObject(InputStream in, Class objectClass, JSONReader.Context context)
    Parses JSONB from an input stream to an object of the specified class using the specified context
    static <T> T
    parseObject(InputStream in, Class objectClass, JSONReader.Feature... features)
    Parses JSONB from an input stream to an object of the specified class
    static <T> T
    parseObject(InputStream in, Type objectType, JSONReader.Context context)
    Parses JSONB from an input stream to an object of the specified type using the specified context
    static <T> T
    parseObject(InputStream in, Type objectType, JSONReader.Feature... features)
    Parses JSONB from an input stream to an object of the specified type
    symbolTable(String... names)
    Creates a symbol table with the specified names
    static byte[]
    toBytes(boolean v)
    Converts a boolean value to JSONB bytes
    static byte[]
    toBytes(byte i)
    Converts a byte value to JSONB bytes
    static byte[]
    toBytes(int i)
    Converts an integer value to JSONB bytes
    static byte[]
    toBytes(long i)
    Converts a long value to JSONB bytes
    static byte[]
    toBytes(short i)
    Converts a short value to JSONB bytes
    static byte[]
    toBytes(Object object)
    Converts an object to JSONB bytes
    static byte[]
    toBytes(Object object, JSONWriter.Context context)
    Converts an object to JSONB bytes with specified context
    static byte[]
    toBytes(Object object, JSONWriter.Context context, SymbolTable symbolTable, JSONWriter.Feature... features)
    Converts an object to JSONB bytes with specified context, symbol table and features
    static byte[]
    toBytes(Object object, JSONWriter.Feature... features)
    Converts an object to JSONB bytes with specified features
    static byte[]
    toBytes(Object object, SymbolTable symbolTable)
    Converts an object to JSONB bytes with a symbol table
    static byte[]
    toBytes(Object object, SymbolTable symbolTable, Filter[] filters, JSONWriter.Feature... features)
    Converts an object to JSONB bytes with a symbol table, filters and features
    static byte[]
    toBytes(Object object, SymbolTable symbolTable, JSONWriter.Feature... features)
    Converts an object to JSONB bytes with a symbol table and features
    static byte[]
    Converts a string to JSONB bytes
    static byte[]
    toBytes(String str, Charset charset)
    Converts a string to JSONB bytes with specified charset
    static String
    toJSONString(byte[] jsonbBytes)
    Converts JSONB bytes to a JSON string
    static String
    toJSONString(byte[] jsonbBytes, boolean raw)
    Converts JSONB bytes to a JSON string
    static String
    toJSONString(byte[] jsonbBytes, SymbolTable symbolTable)
    Converts JSONB bytes to a JSON string with a symbol table
    static String
    toJSONString(byte[] jsonbBytes, SymbolTable symbolTable, boolean raw)
    Converts JSONB bytes to a JSON string with a symbol table
    static String
    typeName(byte type)
    Gets the type name for the specified type byte
    static int
    writeTo(OutputStream out, Object object, JSONWriter.Feature... features)
    Writes an object to an output stream as JSONB bytes
  • Method Details

    • dump

      static void dump(byte[] jsonbBytes)
      Dumps the JSONB bytes to standard output for debugging purposes
      Parameters:
      jsonbBytes - the JSONB bytes to dump
    • dump

      static void dump(byte[] jsonbBytes, SymbolTable symbolTable)
      Dumps the JSONB bytes to standard output for debugging purposes with a symbol table
      Parameters:
      jsonbBytes - the JSONB bytes to dump
      symbolTable - the symbol table to use
    • toBytes

      static byte[] toBytes(boolean v)
      Converts a boolean value to JSONB bytes
      Parameters:
      v - the boolean value to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(int i)
      Converts an integer value to JSONB bytes
      Parameters:
      i - the integer value to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(byte i)
      Converts a byte value to JSONB bytes
      Parameters:
      i - the byte value to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(short i)
      Converts a short value to JSONB bytes
      Parameters:
      i - the short value to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(long i)
      Converts a long value to JSONB bytes
      Parameters:
      i - the long value to convert
      Returns:
      the JSONB bytes representation
    • parse

      static Object parse(byte[] jsonbBytes, JSONReader.Context context)
      Parses JSONB bytes to an object using the specified context
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      context - the JSON reader context
      Returns:
      the parsed object
      Since:
      2.0.46
    • parse

      static Object parse(byte[] jsonbBytes, JSONReader.Feature... features)
      Parses JSONB bytes to an object with specified features
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parse

      static Object parse(InputStream in, JSONReader.Context context)
      Parses JSONB from an input stream to an object using the specified context
      Parameters:
      in - the input stream to parse from
      context - the JSON reader context
      Returns:
      the parsed object
    • parse

      static Object parse(byte[] jsonbBytes, SymbolTable symbolTable, JSONReader.Feature... features)
      Parses JSONB bytes to an object with a symbol table and features
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      symbolTable - the symbol table to use
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static JSONObject parseObject(byte[] jsonbBytes)
      Parses JSONB bytes to a JSONObject
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      Returns:
      the parsed JSONObject
    • parseObject

      static JSONObject parseObject(byte[] jsonbBytes, JSONReader.Feature... features)
      Parses JSONB bytes to a JSONObject with specified features
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      features - the JSON reader features to apply
      Returns:
      the parsed JSONObject
    • parseObject

      static JSONObject parseObject(InputStream in, JSONReader.Context context)
      Parses JSONB bytes to a JSONObject using the specified context
      Parameters:
      in - the input stream to parse from
      context - the JSON reader context
      Returns:
      the parsed JSONObject
    • parseArray

      static JSONArray parseArray(byte[] jsonbBytes)
      Parses JSONB bytes to a JSONArray
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      Returns:
      the parsed JSONArray
    • parseArray

      static JSONArray parseArray(InputStream in, JSONReader.Context context)
      Parses JSONB from an input stream to a JSONArray using the specified context
      Parameters:
      in - the input stream to parse from
      context - the JSON reader context
      Returns:
      the parsed JSONArray
    • parseArray

      static <T> List<T> parseArray(byte[] jsonbBytes, Type type)
      Parses JSONB bytes to a list of objects of the specified type
      Type Parameters:
      T - the type of objects in the list
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      type - the type of objects in the list
      Returns:
      the parsed list of objects
    • parseArray

      static <T> List<T> parseArray(byte[] jsonbBytes, Type type, JSONReader.Feature... features)
      Parses JSONB bytes to a list of objects of the specified type with features
      Type Parameters:
      T - the type of objects in the list
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      type - the type of objects in the list
      features - the JSON reader features to apply
      Returns:
      the parsed list of objects
    • parseArray

      static <T> List<T> parseArray(byte[] jsonbBytes, Type... types)
      Parses JSONB bytes to a list of objects with specified types
      Type Parameters:
      T - the type of objects in the list
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      types - the types of objects in the list
      Returns:
      the parsed list of objects
    • parseArray

      static <T> List<T> parseArray(byte[] jsonbBytes, Type[] types, JSONReader.Feature... features)
      Parses JSONB bytes to a list of objects with specified types and features
      Type Parameters:
      T - the type of objects in the list
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      types - the types of objects in the list
      features - the JSON reader features to apply
      Returns:
      the parsed list of objects
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Class<T> objectClass)
      Parses JSONB bytes to an object of the specified class
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectClass - the class of the object to parse to
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type objectType)
      Parses JSONB bytes to an object of the specified type
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectType - the type of the object to parse to
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type... types)
      Parses JSONB bytes to an object with specified types
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      types - the types of the object to parse to
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable)
      Parses JSONB bytes to an object of the specified type with a symbol table
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectType - the type of the object to parse to
      symbolTable - the symbol table to use
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified type with a symbol table and features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectType - the type of the object to parse to
      symbolTable - the symbol table to use
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Class<T> objectClass, Filter filter, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified class with a filter and features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectClass - the class of the object to parse to
      filter - the filter to apply
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable, Filter[] filters, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified type with a symbol table, filters and features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectType - the type of the object to parse to
      symbolTable - the symbol table to use
      filters - the filters to apply
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • copy

      static <T> T copy(T object, JSONWriter.Feature... features)
      Creates a deep copy of the specified object
      Type Parameters:
      T - the type of the object
      Parameters:
      object - the object to copy
      features - the JSON writer features to apply
      Returns:
      a deep copy of the object
      Since:
      2.0.30
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, TypeReference typeReference, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified type reference
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      typeReference - the type reference of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(InputStream in, Class objectClass, JSONReader.Feature... features) throws IOException
      Parses JSONB from an input stream to an object of the specified class
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      objectClass - the class of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
      Throws:
      IOException - if an I/O error occurs
      Since:
      2.0.30
    • parseObject

      static <T> T parseObject(InputStream in, Type objectType, JSONReader.Feature... features) throws IOException
      Parses JSONB from an input stream to an object of the specified type
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      objectType - the type of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
      Throws:
      IOException - if an I/O error occurs
      Since:
      2.0.30
    • parseObject

      static <T> T parseObject(InputStream in, Type objectType, JSONReader.Context context)
      Parses JSONB from an input stream to an object of the specified type using the specified context
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      objectType - the type of the object to parse to
      context - the JSON reader context
      Returns:
      the parsed object
      Since:
      2.0.30
    • parseObject

      static <T> T parseObject(InputStream in, Class objectClass, JSONReader.Context context)
      Parses JSONB from an input stream to an object of the specified class using the specified context
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      objectClass - the class of the object to parse to
      context - the JSON reader context
      Returns:
      the parsed object
      Since:
      2.0.30
    • parseObject

      static <T> T parseObject(InputStream in, int length, Type objectType, JSONReader.Context context) throws IOException
      Parses JSONB from an input stream with specified length to an object of the specified type using the specified context
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      length - the length of data to read
      objectType - the type of the object to parse to
      context - the JSON reader context
      Returns:
      the parsed object
      Throws:
      IOException - if an I/O error occurs
    • parseObject

      static <T> T parseObject(InputStream in, int length, Type objectType, JSONReader.Feature... features) throws IOException
      Parses JSONB from an input stream with specified length to an object of the specified type with features
      Type Parameters:
      T - the type of the object
      Parameters:
      in - the input stream to parse from
      length - the length of data to read
      objectType - the type of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
      Throws:
      IOException - if an I/O error occurs
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified class with features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectClass - the class of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Context context)
      Parses JSONB bytes to an object of the specified class using the specified context
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectClass - the class of the object to parse to
      context - the JSON reader context
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, Type objectClass, JSONReader.Feature... features)
      Parses JSONB bytes to an object of the specified type with features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      objectClass - the type of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass)
      Parses JSONB bytes with offset and length to an object of the specified class
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the class of the object to parse to
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Type type)
      Parses JSONB bytes with offset and length to an object of the specified type
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      type - the type of the object to parse to
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, JSONReader.Feature... features)
      Parses JSONB bytes with offset and length to an object of the specified class with features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the class of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Type objectType, JSONReader.Context context)
      Parses JSONB bytes with offset and length to an object of the specified type using the specified context
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectType - the type of the object to parse to
      context - the JSON reader context
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Type objectType, JSONReader.Feature... features)
      Parses JSONB bytes with offset and length to an object of the specified type with features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectType - the type of the object to parse to
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, SymbolTable symbolTable)
      Parses JSONB bytes with offset and length to an object of the specified class with a symbol table
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the class of the object to parse to
      symbolTable - the symbol table to use
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Type objectClass, SymbolTable symbolTable)
      Parses JSONB bytes with offset and length to an object of the specified type with a symbol table
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the type of the object to parse to
      symbolTable - the symbol table to use
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass, SymbolTable symbolTable, JSONReader.Feature... features)
      Parses JSONB bytes with offset and length to an object of the specified class with a symbol table and features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the class of the object to parse to
      symbolTable - the symbol table to use
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • parseObject

      static <T> T parseObject(byte[] jsonbBytes, int off, int len, Type objectClass, SymbolTable symbolTable, JSONReader.Feature... features)
      Parses JSONB bytes with offset and length to an object of the specified type with a symbol table and features
      Type Parameters:
      T - the type of the object
      Parameters:
      jsonbBytes - the JSONB bytes to parse
      off - the offset in the byte array
      len - the length of data to parse
      objectClass - the type of the object to parse to
      symbolTable - the symbol table to use
      features - the JSON reader features to apply
      Returns:
      the parsed object
    • toBytes

      static byte[] toBytes(String str)
      Converts a string to JSONB bytes
      Parameters:
      str - the string to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(String str, Charset charset)
      Converts a string to JSONB bytes with specified charset
      Parameters:
      str - the string to convert
      charset - the charset to use
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object)
      Converts an object to JSONB bytes
      Parameters:
      object - the object to convert
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, JSONWriter.Context context)
      Converts an object to JSONB bytes with specified context
      Parameters:
      object - the object to convert
      context - the JSON writer context
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, SymbolTable symbolTable)
      Converts an object to JSONB bytes with a symbol table
      Parameters:
      object - the object to convert
      symbolTable - the symbol table to use
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, SymbolTable symbolTable, JSONWriter.Feature... features)
      Converts an object to JSONB bytes with a symbol table and features
      Parameters:
      object - the object to convert
      symbolTable - the symbol table to use
      features - the JSON writer features to apply
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, JSONWriter.Context context, SymbolTable symbolTable, JSONWriter.Feature... features)
      Converts an object to JSONB bytes with specified context, symbol table and features
      Parameters:
      object - the object to convert
      context - the JSON writer context
      symbolTable - the symbol table to use
      features - the JSON writer features to apply
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, SymbolTable symbolTable, Filter[] filters, JSONWriter.Feature... features)
      Converts an object to JSONB bytes with a symbol table, filters and features
      Parameters:
      object - the object to convert
      symbolTable - the symbol table to use
      filters - the filters to apply
      features - the JSON writer features to apply
      Returns:
      the JSONB bytes representation
    • toBytes

      static byte[] toBytes(Object object, JSONWriter.Feature... features)
      Converts an object to JSONB bytes with specified features
      Parameters:
      object - the object to convert
      features - the JSON writer features to apply
      Returns:
      the JSONB bytes representation
    • symbolTable

      static SymbolTable symbolTable(String... names)
      Creates a symbol table with the specified names
      Parameters:
      names - the names to include in the symbol table
      Returns:
      the created symbol table
    • toJSONString

      static String toJSONString(byte[] jsonbBytes)
      Converts JSONB bytes to a JSON string
      Parameters:
      jsonbBytes - the JSONB bytes to convert
      Returns:
      the JSON string representation
    • toJSONString

      static String toJSONString(byte[] jsonbBytes, boolean raw)
      Converts JSONB bytes to a JSON string
      Parameters:
      jsonbBytes - the JSONB bytes to convert
      raw - whether to use raw format
      Returns:
      the JSON string representation
      Since:
      2.0.28
    • toJSONString

      static String toJSONString(byte[] jsonbBytes, SymbolTable symbolTable)
      Converts JSONB bytes to a JSON string with a symbol table
      Parameters:
      jsonbBytes - the JSONB bytes to convert
      symbolTable - the symbol table to use
      Returns:
      the JSON string representation
    • toJSONString

      static String toJSONString(byte[] jsonbBytes, SymbolTable symbolTable, boolean raw)
      Converts JSONB bytes to a JSON string with a symbol table
      Parameters:
      jsonbBytes - the JSONB bytes to convert
      symbolTable - the symbol table to use
      raw - whether to use raw format
      Returns:
      the JSON string representation
    • writeTo

      static int writeTo(OutputStream out, Object object, JSONWriter.Feature... features)
      Writes an object to an output stream as JSONB bytes
      Parameters:
      out - the output stream to write to
      object - the object to write
      features - the JSON writer features to apply
      Returns:
      the number of bytes written
    • fromJSONString

      static byte[] fromJSONString(String str)
      Converts a JSON string to JSONB bytes
      Parameters:
      str - the JSON string to convert
      Returns:
      the JSONB bytes representation
    • fromJSONBytes

      static byte[] fromJSONBytes(byte[] jsonUtf8Bytes)
      Converts JSON bytes to JSONB bytes
      Parameters:
      jsonUtf8Bytes - the JSON bytes to convert
      Returns:
      the JSONB bytes representation
    • typeName

      static String typeName(byte type)
      Gets the type name for the specified type byte
      Parameters:
      type - the type byte
      Returns:
      the type name
    • isInt32

      static boolean isInt32(int type)
      Checks if the specified type is an int32 type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int32 type, false otherwise
    • isInt32Num

      static boolean isInt32Num(int type)
      Checks if the specified type is an int32 number type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int32 number type, false otherwise
    • isInt32Byte

      static boolean isInt32Byte(int type)
      Checks if the specified type is an int32 byte type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int32 byte type, false otherwise
    • isInt32Short

      static boolean isInt32Short(int type)
      Checks if the specified type is an int32 short type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int32 short type, false otherwise
    • isInt64Num

      static boolean isInt64Num(int type)
      Checks if the specified type is an int64 number type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int64 number type, false otherwise
    • isInt64Byte

      static boolean isInt64Byte(int type)
      Checks if the specified type is an int64 byte type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int64 byte type, false otherwise
    • isInt64Short

      static boolean isInt64Short(int type)
      Checks if the specified type is an int64 short type
      Parameters:
      type - the type to check
      Returns:
      true if the type is an int64 short type, false otherwise
    • isInt32ByteValue

      static boolean isInt32ByteValue(int i)
      Checks if the specified integer value can be represented as an int32 byte value
      Parameters:
      i - the integer value to check
      Returns:
      true if the value can be represented as an int32 byte value, false otherwise
    • isInt32ByteValue1

      static boolean isInt32ByteValue1(int i)
      Checks if the specified integer value is within the int32 byte value range
      Parameters:
      i - the integer value to check
      Returns:
      true if the value is within the int32 byte value range, false otherwise