Package com.alibaba.fastjson2
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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceConstants for JSONB binary format specificationstatic interfaceIO utility methods for JSONB serialization -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> Tcopy(T object, JSONWriter.Feature... features) Creates a deep copy of the specified objectstatic voiddump(byte[] jsonbBytes) Dumps the JSONB bytes to standard output for debugging purposesstatic voiddump(byte[] jsonbBytes, SymbolTable symbolTable) Dumps the JSONB bytes to standard output for debugging purposes with a symbol tablestatic byte[]fromJSONBytes(byte[] jsonUtf8Bytes) Converts JSON bytes to JSONB bytesstatic byte[]fromJSONString(String str) Converts a JSON string to JSONB bytesstatic booleanisInt32(int type) Checks if the specified type is an int32 typestatic booleanisInt32Byte(int type) Checks if the specified type is an int32 byte typestatic booleanisInt32ByteValue(int i) Checks if the specified integer value can be represented as an int32 byte valuestatic booleanisInt32ByteValue1(int i) Checks if the specified integer value is within the int32 byte value rangestatic booleanisInt32Num(int type) Checks if the specified type is an int32 number typestatic booleanisInt32Short(int type) Checks if the specified type is an int32 short typestatic booleanisInt64Byte(int type) Checks if the specified type is an int64 byte typestatic booleanisInt64Num(int type) Checks if the specified type is an int64 number typestatic booleanisInt64Short(int type) Checks if the specified type is an int64 short typestatic Objectparse(byte[] jsonbBytes, JSONReader.Context context) Parses JSONB bytes to an object using the specified contextstatic Objectparse(byte[] jsonbBytes, JSONReader.Feature... features) Parses JSONB bytes to an object with specified featuresstatic Objectparse(byte[] jsonbBytes, SymbolTable symbolTable, JSONReader.Feature... features) Parses JSONB bytes to an object with a symbol table and featuresstatic Objectparse(InputStream in, JSONReader.Context context) Parses JSONB from an input stream to an object using the specified contextstatic JSONArrayparseArray(byte[] jsonbBytes) Parses JSONB bytes to a JSONArraystatic <T> List<T> parseArray(byte[] jsonbBytes, Type type) Parses JSONB bytes to a list of objects of the specified typestatic <T> List<T> parseArray(byte[] jsonbBytes, Type... types) Parses JSONB bytes to a list of objects with specified typesstatic <T> List<T> parseArray(byte[] jsonbBytes, Type[] types, JSONReader.Feature... features) Parses JSONB bytes to a list of objects with specified types and featuresstatic <T> List<T> parseArray(byte[] jsonbBytes, Type type, JSONReader.Feature... features) Parses JSONB bytes to a list of objects of the specified type with featuresstatic JSONArrayparseArray(InputStream in, JSONReader.Context context) Parses JSONB from an input stream to a JSONArray using the specified contextstatic JSONObjectparseObject(byte[] jsonbBytes) Parses JSONB bytes to a JSONObjectstatic <T> TparseObject(byte[] jsonbBytes, int off, int len, Class<T> objectClass) Parses JSONB bytes with offset and length to an object of the specified classstatic <T> TparseObject(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 featuresstatic <T> TparseObject(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 tablestatic <T> TparseObject(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 featuresstatic <T> TparseObject(byte[] jsonbBytes, int off, int len, Type type) Parses JSONB bytes with offset and length to an object of the specified typestatic <T> TparseObject(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 contextstatic <T> TparseObject(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 featuresstatic <T> TparseObject(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 tablestatic <T> TparseObject(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 featuresstatic JSONObjectparseObject(byte[] jsonbBytes, JSONReader.Feature... features) Parses JSONB bytes to a JSONObject with specified featuresstatic <T> TparseObject(byte[] jsonbBytes, TypeReference typeReference, JSONReader.Feature... features) Parses JSONB bytes to an object of the specified type referencestatic <T> TparseObject(byte[] jsonbBytes, Class<T> objectClass) Parses JSONB bytes to an object of the specified classstatic <T> TparseObject(byte[] jsonbBytes, Class<T> objectClass, Filter filter, JSONReader.Feature... features) Parses JSONB bytes to an object of the specified class with a filter and featuresstatic <T> TparseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Context context) Parses JSONB bytes to an object of the specified class using the specified contextstatic <T> TparseObject(byte[] jsonbBytes, Class<T> objectClass, JSONReader.Feature... features) Parses JSONB bytes to an object of the specified class with featuresstatic <T> TparseObject(byte[] jsonbBytes, Type objectType) Parses JSONB bytes to an object of the specified typestatic <T> TparseObject(byte[] jsonbBytes, Type... types) Parses JSONB bytes to an object with specified typesstatic <T> TparseObject(byte[] jsonbBytes, Type objectClass, JSONReader.Feature... features) Parses JSONB bytes to an object of the specified type with featuresstatic <T> TparseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable) Parses JSONB bytes to an object of the specified type with a symbol tablestatic <T> TparseObject(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 featuresstatic <T> TparseObject(byte[] jsonbBytes, Type objectType, SymbolTable symbolTable, JSONReader.Feature... features) Parses JSONB bytes to an object of the specified type with a symbol table and featuresstatic <T> TparseObject(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 contextstatic <T> TparseObject(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 featuresstatic JSONObjectparseObject(InputStream in, JSONReader.Context context) Parses JSONB bytes to a JSONObject using the specified contextstatic <T> TparseObject(InputStream in, Class objectClass, JSONReader.Context context) Parses JSONB from an input stream to an object of the specified class using the specified contextstatic <T> TparseObject(InputStream in, Class objectClass, JSONReader.Feature... features) Parses JSONB from an input stream to an object of the specified classstatic <T> TparseObject(InputStream in, Type objectType, JSONReader.Context context) Parses JSONB from an input stream to an object of the specified type using the specified contextstatic <T> TparseObject(InputStream in, Type objectType, JSONReader.Feature... features) Parses JSONB from an input stream to an object of the specified typestatic SymbolTablesymbolTable(String... names) Creates a symbol table with the specified namesstatic byte[]toBytes(boolean v) Converts a boolean value to JSONB bytesstatic byte[]toBytes(byte i) Converts a byte value to JSONB bytesstatic byte[]toBytes(int i) Converts an integer value to JSONB bytesstatic byte[]toBytes(long i) Converts a long value to JSONB bytesstatic byte[]toBytes(short i) Converts a short value to JSONB bytesstatic byte[]Converts an object to JSONB bytesstatic byte[]toBytes(Object object, JSONWriter.Context context) Converts an object to JSONB bytes with specified contextstatic byte[]toBytes(Object object, JSONWriter.Context context, SymbolTable symbolTable, JSONWriter.Feature... features) Converts an object to JSONB bytes with specified context, symbol table and featuresstatic byte[]toBytes(Object object, JSONWriter.Feature... features) Converts an object to JSONB bytes with specified featuresstatic byte[]toBytes(Object object, SymbolTable symbolTable) Converts an object to JSONB bytes with a symbol tablestatic byte[]toBytes(Object object, SymbolTable symbolTable, Filter[] filters, JSONWriter.Feature... features) Converts an object to JSONB bytes with a symbol table, filters and featuresstatic byte[]toBytes(Object object, SymbolTable symbolTable, JSONWriter.Feature... features) Converts an object to JSONB bytes with a symbol table and featuresstatic byte[]Converts a string to JSONB bytesstatic byte[]Converts a string to JSONB bytes with specified charsetstatic StringtoJSONString(byte[] jsonbBytes) Converts JSONB bytes to a JSON stringstatic StringtoJSONString(byte[] jsonbBytes, boolean raw) Converts JSONB bytes to a JSON stringstatic StringtoJSONString(byte[] jsonbBytes, SymbolTable symbolTable) Converts JSONB bytes to a JSON string with a symbol tablestatic StringtoJSONString(byte[] jsonbBytes, SymbolTable symbolTable, boolean raw) Converts JSONB bytes to a JSON string with a symbol tablestatic StringtypeName(byte type) Gets the type name for the specified type bytestatic intwriteTo(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
Dumps the JSONB bytes to standard output for debugging purposes with a symbol table- Parameters:
jsonbBytes- the JSONB bytes to dumpsymbolTable- 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
Parses JSONB bytes to an object using the specified context- Parameters:
jsonbBytes- the JSONB bytes to parsecontext- the JSON reader context- Returns:
- the parsed object
- Since:
- 2.0.46
-
parse
Parses JSONB bytes to an object with specified features- Parameters:
jsonbBytes- the JSONB bytes to parsefeatures- the JSON reader features to apply- Returns:
- the parsed object
-
parse
Parses JSONB from an input stream to an object using the specified context- Parameters:
in- the input stream to parse fromcontext- the JSON reader context- Returns:
- the parsed object
-
parse
Parses JSONB bytes to an object with a symbol table and features- Parameters:
jsonbBytes- the JSONB bytes to parsesymbolTable- the symbol table to usefeatures- the JSON reader features to apply- Returns:
- the parsed object
-
parseObject
Parses JSONB bytes to a JSONObject- Parameters:
jsonbBytes- the JSONB bytes to parse- Returns:
- the parsed JSONObject
-
parseObject
Parses JSONB bytes to a JSONObject with specified features- Parameters:
jsonbBytes- the JSONB bytes to parsefeatures- the JSON reader features to apply- Returns:
- the parsed JSONObject
-
parseObject
Parses JSONB bytes to a JSONObject using the specified context- Parameters:
in- the input stream to parse fromcontext- the JSON reader context- Returns:
- the parsed JSONObject
-
parseArray
Parses JSONB bytes to a JSONArray- Parameters:
jsonbBytes- the JSONB bytes to parse- Returns:
- the parsed JSONArray
-
parseArray
Parses JSONB from an input stream to a JSONArray using the specified context- Parameters:
in- the input stream to parse fromcontext- the JSON reader context- Returns:
- the parsed JSONArray
-
parseArray
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 parsetype- the type of objects in the list- Returns:
- the parsed list of objects
-
parseArray
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 parsetype- the type of objects in the listfeatures- the JSON reader features to apply- Returns:
- the parsed list of objects
-
parseArray
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 parsetypes- the types of objects in the list- Returns:
- the parsed list of objects
-
parseArray
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 parsetypes- the types of objects in the listfeatures- the JSON reader features to apply- Returns:
- the parsed list of objects
-
parseObject
Parses JSONB bytes to an object of the specified class- Type Parameters:
T- the type of the object- Parameters:
jsonbBytes- the JSONB bytes to parseobjectClass- the class of the object to parse to- Returns:
- the parsed object
-
parseObject
Parses JSONB bytes to an object of the specified type- Type Parameters:
T- the type of the object- Parameters:
jsonbBytes- the JSONB bytes to parseobjectType- the type of the object to parse to- Returns:
- the parsed object
-
parseObject
Parses JSONB bytes to an object with specified types- Type Parameters:
T- the type of the object- Parameters:
jsonbBytes- the JSONB bytes to parsetypes- the types of the object to parse to- Returns:
- the parsed object
-
parseObject
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 parseobjectType- the type of the object to parse tosymbolTable- 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 parseobjectType- the type of the object to parse tosymbolTable- the symbol table to usefeatures- 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 parseobjectClass- the class of the object to parse tofilter- the filter to applyfeatures- 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 parseobjectType- the type of the object to parse tosymbolTable- the symbol table to usefilters- the filters to applyfeatures- the JSON reader features to apply- Returns:
- the parsed object
-
copy
Creates a deep copy of the specified object- Type Parameters:
T- the type of the object- Parameters:
object- the object to copyfeatures- 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 parsetypeReference- the type reference of the object to parse tofeatures- 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 fromobjectClass- the class of the object to parse tofeatures- 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 fromobjectType- the type of the object to parse tofeatures- the JSON reader features to apply- Returns:
- the parsed object
- Throws:
IOException- if an I/O error occurs- Since:
- 2.0.30
-
parseObject
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 fromobjectType- the type of the object to parse tocontext- the JSON reader context- Returns:
- the parsed object
- Since:
- 2.0.30
-
parseObject
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 fromobjectClass- the class of the object to parse tocontext- 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 fromlength- the length of data to readobjectType- the type of the object to parse tocontext- 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 fromlength- the length of data to readobjectType- the type of the object to parse tofeatures- the JSON reader features to apply- Returns:
- the parsed object
- Throws:
IOException- if an I/O error occurs
-
parseObject
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 parseobjectClass- the class of the object to parse tofeatures- the JSON reader features to apply- Returns:
- the parsed object
-
parseObject
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 parseobjectClass- the class of the object to parse tocontext- the JSON reader context- Returns:
- the parsed object
-
parseObject
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 parseobjectClass- the type of the object to parse tofeatures- the JSON reader features to apply- Returns:
- the parsed object
-
parseObject
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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the class of the object to parse to- Returns:
- the parsed object
-
parseObject
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 parseoff- the offset in the byte arraylen- the length of data to parsetype- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the class of the object to parse tofeatures- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectType- the type of the object to parse tocontext- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectType- the type of the object to parse tofeatures- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the class of the object to parse tosymbolTable- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the type of the object to parse tosymbolTable- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the class of the object to parse tosymbolTable- the symbol table to usefeatures- 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 parseoff- the offset in the byte arraylen- the length of data to parseobjectClass- the type of the object to parse tosymbolTable- the symbol table to usefeatures- the JSON reader features to apply- Returns:
- the parsed object
-
toBytes
Converts a string to JSONB bytes- Parameters:
str- the string to convert- Returns:
- the JSONB bytes representation
-
toBytes
Converts a string to JSONB bytes with specified charset- Parameters:
str- the string to convertcharset- the charset to use- Returns:
- the JSONB bytes representation
-
toBytes
Converts an object to JSONB bytes- Parameters:
object- the object to convert- Returns:
- the JSONB bytes representation
-
toBytes
Converts an object to JSONB bytes with specified context- Parameters:
object- the object to convertcontext- the JSON writer context- Returns:
- the JSONB bytes representation
-
toBytes
Converts an object to JSONB bytes with a symbol table- Parameters:
object- the object to convertsymbolTable- the symbol table to use- Returns:
- the JSONB bytes representation
-
toBytes
Converts an object to JSONB bytes with a symbol table and features- Parameters:
object- the object to convertsymbolTable- the symbol table to usefeatures- 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 convertcontext- the JSON writer contextsymbolTable- the symbol table to usefeatures- 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 convertsymbolTable- the symbol table to usefilters- the filters to applyfeatures- the JSON writer features to apply- Returns:
- the JSONB bytes representation
-
toBytes
Converts an object to JSONB bytes with specified features- Parameters:
object- the object to convertfeatures- the JSON writer features to apply- Returns:
- the JSONB bytes representation
-
symbolTable
Creates a symbol table with the specified names- Parameters:
names- the names to include in the symbol table- Returns:
- the created symbol table
-
toJSONString
Converts JSONB bytes to a JSON string- Parameters:
jsonbBytes- the JSONB bytes to convert- Returns:
- the JSON string representation
-
toJSONString
Converts JSONB bytes to a JSON string- Parameters:
jsonbBytes- the JSONB bytes to convertraw- whether to use raw format- Returns:
- the JSON string representation
- Since:
- 2.0.28
-
toJSONString
Converts JSONB bytes to a JSON string with a symbol table- Parameters:
jsonbBytes- the JSONB bytes to convertsymbolTable- the symbol table to use- Returns:
- the JSON string representation
-
toJSONString
Converts JSONB bytes to a JSON string with a symbol table- Parameters:
jsonbBytes- the JSONB bytes to convertsymbolTable- the symbol table to useraw- whether to use raw format- Returns:
- the JSON string representation
-
writeTo
Writes an object to an output stream as JSONB bytes- Parameters:
out- the output stream to write toobject- the object to writefeatures- the JSON writer features to apply- Returns:
- the number of bytes written
-
fromJSONString
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
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
-