Package com.alibaba.fastjson2
Interface JSON
public interface JSON
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfig(JSONReader.Feature... features) Enable the specified features in default readerstatic voidconfig(JSONReader.Feature feature, boolean state) Enable or disable the specified features in default readerstatic voidconfig(JSONWriter.Feature... features) Enable the specified features in default writerstatic voidconfig(JSONWriter.Feature feature, boolean state) Enable or disable the specified features in default writerstatic <T> Tcopy(T object, JSONWriter.Feature... features) use ObjectWriter and ObjectReader copy java objectstatic <T> TcopyTo(Object object, Class<T> targetClass, JSONWriter.Feature... features) use ObjectWriter and ObjectReader copy java objectstatic booleanisEnabled(JSONReader.Feature feature) Check if the default reader enables the specified featurestatic booleanisEnabled(JSONWriter.Feature feature) Check if the default writer enables the specified featurestatic booleanisValid(byte[] bytes) Verify the byte array is JSON Objectstatic booleanVerify the byte array is JSON Objectstatic booleanisValid(char[] chars) Verify the char array is JSONstatic booleanVerify theStringis JSONstatic booleanisValidArray(byte[] bytes) Verify the byte array is JSON Arraystatic booleanisValidArray(String text) Verify theStringis JSON Arraystatic booleanisValidObject(byte[] bytes) Verify the byte array is JSON Objectstatic booleanisValidObject(String text) Verify theStringis JSON Objectstatic voidstatic Objectparse(byte[] bytes, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoJSONArrayorJSONObjectwith specifiedJSONReader.Features enabledstatic Objectparse(char[] chars, JSONReader.Feature... features) static Objectstatic Objectparse(String text, int offset, int length, JSONReader.Feature... features) static Objectparse(String text, JSONReader.Context context) static Objectparse(String text, JSONReader.Feature... features) static JSONArrayparseArray(byte[] bytes) static JSONArrayparseArray(byte[] bytes, int offset, int length, Charset charset) static <T> List<T>parseArray(byte[] bytes, int offset, int length, Charset charset, Class<T> type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabledstatic <T> List<T>parseArray(byte[] bytes, Class<T> type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabledstatic <T> List<T>parseArray(byte[] bytes, Type type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabledstatic JSONArrayparseArray(char[] chars) static <T> List<T>parseArray(char[] chars, Class<T> type, JSONReader.Feature... features) static JSONArrayparseArray(InputStream in, JSONReader.Feature... features) Parse JSONInputStreamintoJSONArraystatic JSONArrayparseArray(String text) static JSONArrayparseArray(String text, JSONReader.Feature... features) static <T> List<T>parseArray(String text, Class<T> type, JSONReader.Feature... features) static <T> List<T>parseArray(String text, Type type) static <T> List<T>parseArray(String text, Type... types) static <T> List<T>parseArray(String text, Type[] types, JSONReader.Feature... features) static <T> List<T>parseArray(String text, Type type, JSONReader.Feature... features) static JSONArrayparseArray(URL url, JSONReader.Feature... features) Parse JSONInputStreamintoJSONArraystatic JSONObjectparseObject(byte[] bytes) Parse UTF8 encoded JSON byte array intoJSONObjectstatic JSONObjectparseObject(byte[] bytes, int offset, int length, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoJSONObjectstatic <T> TparseObject(byte[] bytes, int offset, int length, Type type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java objectstatic JSONObjectparseObject(byte[] bytes, int offset, int length, Charset charset, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoJSONObjectstatic <T> TparseObject(byte[] bytes, int offset, int length, Charset charset, Class<T> type, JSONReader.Feature... features) Parses the JSON byte array of the specifiedCharsetinto a Java Objectstatic <T> TparseObject(byte[] bytes, int offset, int length, Charset charset, Type type) Parses the JSON byte array of the specifiedCharsetinto a Java Objectstatic JSONObjectparseObject(byte[] bytes, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoJSONObjectstatic <T> TparseObject(byte[] bytes, Class<T> clazz) Parse UTF8 encoded JSON byte array into a Java objectstatic <T> TparseObject(byte[] utf8Bytes, Class<T> clazz, Filter filter, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java objectstatic <T> TparseObject(byte[] utf8Bytes, Class<T> clazz, JSONReader.Context context) Parse UTF8 encoded JSON byte array into a Java objectstatic <T> TparseObject(byte[] bytes, Class<T> clazz, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(byte[] bytes, Type type) Parse UTF8 encoded JSON byte array into a Java objectstatic <T> TparseObject(byte[] bytes, Type type, Filter filter, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(byte[] bytes, Type type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(byte[] utf8Bytes, Type type, String format, Filter[] filters, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java objectstatic <T> TparseObject(byte[] bytes, Type type, String format, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabledstatic JSONObjectparseObject(char[] chars) Parse JSON char array intoJSONObjectstatic JSONObjectparseObject(char[] chars, int offset, int length, JSONReader.Feature... features) Parse JSON char array intoJSONObjectstatic <T> TparseObject(char[] chars, int offset, int length, Type type, JSONReader.Feature... features) Parse JSON char array into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(char[] chars, Class<T> clazz) Parse JSON char array into a Java objectstatic JSONObjectparseObject(InputStream input, JSONReader.Feature... features) Parse UTF8 inputStream into intoJSONObjectstatic <T> TparseObject(InputStream input, Type type, JSONReader.Feature... features) Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(InputStream input, Type type, String format, JSONReader.Feature... features) Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabledstatic <T> voidparseObject(InputStream input, Type type, Consumer<T> consumer, JSONReader.Feature... features) ParseInputStreaminto a Java object with specifiedJSONReader.Features enabled and consume itstatic JSONObjectparseObject(InputStream in, Charset charset) Parse UTF8 encoded JSON byte array intoJSONObjectstatic <T> voidparseObject(InputStream input, Charset charset, char delimiter, Type type, Consumer<T> consumer, JSONReader.Feature... features) ParseInputStreaminto a Java object with specifiedJSONReader.Features enabled and consume itstatic <T> TparseObject(InputStream input, Charset charset, Type type, JSONReader.Feature... features) Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabledstatic <T> voidparseObject(Reader input, char delimiter, Type type, Consumer<T> consumer) ParseReaderinto a Java object with specifiedJSONReader.Features enabled and consume itstatic JSONObjectparseObject(Reader input, JSONReader.Feature... features) Parse Reader into intoJSONObjectstatic <T> TparseObject(Reader input, Type type, JSONReader.Feature... features) Parse Reader into a Java object with specifiedJSONReader.Features enabledstatic JSONObjectparseObject(String text) Parse JSONStringintoJSONObjectstatic JSONObjectparseObject(String text, int offset, int length, JSONReader.Feature... features) Parse JSONStringintoJSONObjectstatic <T> TparseObject(String text, int offset, int length, Class<T> clazz, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic JSONObjectparseObject(String text, JSONReader.Context context) Parse JSONStringintoJSONObjectstatic JSONObjectparseObject(String text, JSONReader.Feature... features) Parse JSONStringintoJSONObjectstatic <T> TparseObject(String text, TypeReference typeReference, Filter filter, JSONReader.Feature... features) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, TypeReference typeReference, JSONReader.Feature... features) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, Class<T> clazz) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, Class<T> clazz, Filter filter, JSONReader.Feature... features) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, Class<T> clazz, JSONReader.Context context) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(String text, Class<T> clazz, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(String text, Class<T> clazz, String format, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(String text, Type type) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, Type... types) static <T> TparseObject(String text, Type type, Filter filter, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(String text, Type type, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(String text, Type type, String format, Filter[] filters, JSONReader.Feature... features) Parse JSONStringinto Java Objectstatic <T> TparseObject(String text, Type type, String format, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabledstatic JSONObjectparseObject(URL url) Parse UTF8 encoded JSON byte array intoJSONObjectstatic <T> TparseObject(URL url, Class<T> objectClass, JSONReader.Feature... features) Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(URL url, Type type, JSONReader.Feature... features) Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabledstatic <T> TparseObject(URL url, Function<JSONObject, T> function, JSONReader.Feature... features) Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabledstatic booleanregister(ObjectReaderModule objectReaderModule) Register anObjectReaderModulein defaultObjectReaderProviderstatic booleanregister(ObjectWriterModule objectWriterModule) Register anObjectWriterModulein defaultObjectWriterProviderstatic voidRegister ObjectWriterFilterstatic ObjectReader<?>register(Type type, ObjectReader<?> objectReader) static ObjectWriter<?>register(Type type, ObjectWriter<?> objectWriter) static ObjectReader<?>registerIfAbsent(Type type, ObjectReader<?> objectReader) static ObjectWriter<?>registerIfAbsent(Type type, ObjectWriter<?> objectWriter) static <T> TConvert the Object to the target typestatic <T> TtoJavaObject(Object object, Class<T> clazz) Deprecated.static ObjectConvert Java object order toJSONArrayorJSONObjectstatic ObjecttoJSON(Object object, JSONWriter.Feature... features) Convert Java object order toJSONArrayorJSONObjectstatic byte[]toJSONBytes(Object object) Serialize Java Object to JSON byte arraystatic byte[]toJSONBytes(Object object, Filter... filters) Serialize Java Object to JSON byte arraystatic byte[]toJSONBytes(Object object, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabledstatic byte[]toJSONBytes(Object object, JSONWriter.Feature... features) Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabledstatic byte[]toJSONBytes(Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabledstatic StringtoJSONString(Object object) Serialize Java Object to JSONStringstatic StringtoJSONString(Object object, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledstatic StringtoJSONString(Object object, Filter filter, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledstatic StringtoJSONString(Object object, JSONWriter.Context context) Serialize Java Object to JSONStringstatic StringtoJSONString(Object object, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledstatic StringtoJSONString(Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledstatic StringtoJSONString(Object object, String format, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabledstatic intwriteTo(OutputStream out, Object object, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabledstatic intwriteTo(OutputStream out, Object object, JSONWriter.Feature... features) Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabledstatic intwriteTo(OutputStream out, Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabled
-
Field Details
-
VERSION
FASTJSON2 version name- See Also:
-
-
Method Details
-
parse
- Parameters:
text- the JSONStringto be parsed- Returns:
- Object
-
parse
- Parameters:
text- the JSONStringto be parsedfeatures- features to be enabled in parsing- Returns:
- Object
-
parse
- Parameters:
text- the JSONStringto be parsedoffset- the index of the first byte to parselength- the number of bytes to parsefeatures- features to be enabled in parsing- Returns:
- Object
-
parse
- Parameters:
text- the JSONStringto be parsedcontext- specify the context use by JSONReader- Returns:
- Object
-
parse
Parse UTF8 encoded JSON byte array intoJSONArrayorJSONObjectwith specifiedJSONReader.Features enabled- Parameters:
bytes- the UTF8 Bytes to be parsedfeatures- features to be enabled in parsing- Returns:
- Object
-
parse
- Parameters:
chars- the char array to be parsedfeatures- features to be enabled in parsing- Returns:
- Object
-
parseObject
Parse JSONStringintoJSONObject- Parameters:
text- the JSONStringto be parsed- Returns:
- JSONObject
-
parseObject
Parse JSONStringintoJSONObject- Parameters:
text- the JSONStringto be parsedfeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse JSONStringintoJSONObject- Parameters:
text- the JSONStringto be parsedoffset- the index of the first byte to parselength- the number of bytes to parsefeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse JSONStringintoJSONObject- Parameters:
text- the JSONStringto be parsedcontext- specify the context use by JSONReader- Returns:
- JSONObject
-
parseObject
Parse Reader into intoJSONObject- Parameters:
input- the JSONInputStreamto be parsedfeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse UTF8 inputStream into intoJSONObject- Parameters:
input- the JSONInputStreamto be parsedfeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
bytes- UTF8 encoded JSON byte array to parse- Returns:
- JSONObject
-
parseObject
Parse JSON char array intoJSONObject- Parameters:
chars- JSON char array to parse- Returns:
- JSONObject
-
parseObject
Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
in- the JSONInputStreamto be parsed- Returns:
- JSONObject
-
parseObject
Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
url- the JSONURLto be parsed- Returns:
- JSONObject
-
parseObject
Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
bytes- UTF8 encoded JSON byte array to parsefeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
bytes- UTF8 encoded JSON byte array to parseoffset- the index of the first byte to parselength- the number of bytes to parsefeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse JSON char array intoJSONObject- Parameters:
chars- JSON char array to parseoffset- the index of the first byte to parselength- the number of chars to parsefeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
static JSONObject parseObject(byte[] bytes, int offset, int length, Charset charset, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoJSONObject- Parameters:
bytes- UTF8 encoded JSON byte array to parseoffset- the index of the first byte to parselength- the number of bytes to parsecharset- specifyCharsetto parsefeatures- features to be enabled in parsing- Returns:
- JSONObject
-
parseObject
Parse JSONStringinto Java Object- Parameters:
text- the JSONStringto be parsedclazz- specify the Class to be converted- Returns:
- Class
-
parseObject
static <T> T parseObject(String text, Class<T> clazz, Filter filter, JSONReader.Feature... features) Parse JSONStringinto Java Object- Parameters:
text- the JSONStringto be parsedclazz- specify the Class to be convertedfilter- specify filter to be enabledfeatures- features to be enabled in parsing- Returns:
- Class
-
parseObject
static <T> T parseObject(String text, Type type, String format, Filter[] filters, JSONReader.Feature... features) Parse JSONStringinto Java Object -
parseObject
Parse JSONStringinto Java Object -
parseObject
-
parseObject
Parse JSONStringinto Java Object- Parameters:
text- the JSONStringto be parsedtypeReference- specify theTypeReferenceto be converted
-
parseObject
static <T> T parseObject(String text, TypeReference typeReference, Filter filter, JSONReader.Feature... features) Parse JSONStringinto Java Object- Parameters:
text- the JSONStringto be parsedtypeReference- specify theTypeReferenceto be convertedfilter- specify filters to be enabled
-
parseObject
Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled- Parameters:
text- the JSONStringto be parsedclazz- specify the Class to be convertedfeatures- features to be enabled in parsing
-
parseObject
static <T> T parseObject(String text, int offset, int length, Class<T> clazz, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled- Parameters:
text- the JSONStringto be parsedoffset- the index of the first byte to parselength- the number of bytes to parseclazz- specify the Class to be convertedfeatures- features to be enabled in parsing
-
parseObject
Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled- Parameters:
text- the JSONStringto be parsedclazz- specify the Class to be converted
-
parseObject
static <T> T parseObject(String text, Class<T> clazz, String format, JSONReader.Feature... features) Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled- Parameters:
text- the JSONStringto be parsedclazz- specify the Class to be convertedformat- the specified date formatfeatures- features to be enabled in parsing
-
parseObject
Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled -
parseObject
Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled -
parseObject
Parse JSONStringinto a Java object with specifiedJSONReader.Features enabled -
parseObject
static <T> T parseObject(char[] chars, int offset, int length, Type type, JSONReader.Feature... features) Parse JSON char array into a Java object with specifiedJSONReader.Features enabled- Parameters:
chars- JSON char array to parseoffset- the index of the first byte to parselength- the number of bytes to parsetype- specify theTypeto be convertedfeatures- features to be enabled in parsing- Since:
- 2.0.13
-
parseObject
Parse JSON char array into a Java object- Parameters:
chars- JSON char array to parseclazz- specify the Class to be converted- Since:
- 2.0.13
-
parseObject
static <T> T parseObject(byte[] bytes, int offset, int length, Type type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object- Parameters:
bytes- UTF8 encoded JSON byte array to parseoffset- the index of the first byte to parselength- the number of bytes to parsetype- specify theTypeto be convertedfeatures- features to be enabled in parsing- Since:
- 2.0.13
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be converted
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object- Parameters:
bytes- UTF8 encoded JSON byte array to parseclazz- specify the Class to be converted
-
parseObject
static <T> T parseObject(byte[] utf8Bytes, Class<T> clazz, Filter filter, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object- Parameters:
utf8Bytes- UTF8 encoded JSON byte array to parseclazz- specify the Class to be convertedfilter- specify filter to be enabledfeatures- features to be enabled in parsing- Returns:
- Class
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object- Parameters:
utf8Bytes- UTF8 encoded JSON byte array to parseclazz- specify the Class to be convertedcontext- specify the context use by JSONReader- Returns:
- Class
-
parseObject
static <T> T parseObject(byte[] utf8Bytes, Type type, String format, Filter[] filters, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array into a Java object- Parameters:
utf8Bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be convertedformat- the specified date formatfilters- specify filters to be enabledfeatures- features to be enabled in parsing- Returns:
- Class
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parseclazz- specify the Class to be convertedfeatures- features to be enabled in parsing
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be convertedfilter- specify filters to be enabledfeatures- features to be enabled in parsing
-
parseObject
Parse UTF8 encoded JSON byte array into a Java object with specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be convertedformat- the specified date formatfeatures- features to be enabled in parsing
-
parseObject
Parse Reader into a Java object with specifiedJSONReader.Features enabled- Parameters:
input- the JSONInputStreamto be parsedtype- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
parseObject
Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabled- Parameters:
input- the JSONInputStreamto be parsedtype- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
parseObject
Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabled- Parameters:
url- the JSONURLto be parsedtype- specify theTypeto be convertedfeatures- features to be enabled in parsing- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed- Since:
- 2.0.4
-
parseObject
Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabled- Parameters:
url- the JSONURLto be parsedobjectClass- specify theClassto be convertedfeatures- features to be enabled in parsing- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed- Since:
- 2.0.9
-
parseObject
Parse UTF8 URL Resource into a Java object with specifiedJSONReader.Features enabled- Parameters:
url- the JSONURLto be parsedfunction- specify theFunctionto be convertedfeatures- features to be enabled in parsing- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed- Since:
- 2.0.4
-
parseObject
static <T> T parseObject(InputStream input, Type type, String format, JSONReader.Feature... features) Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabled- Parameters:
input- the JSONInputStreamto be parsedtype- specify theTypeto be convertedformat- the specified date formatfeatures- features to be enabled in parsing
-
parseObject
static <T> T parseObject(InputStream input, Charset charset, Type type, JSONReader.Feature... features) Parse UTF8 inputStream into a Java object with specifiedJSONReader.Features enabled- Parameters:
input- the JSONInputStreamto be parsedcharset- inputStream charsettype- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
parseObject
Parses the JSON byte array of the specifiedCharsetinto a Java Object- Parameters:
bytes- JSON byte array to parseoffset- the index of the first byte to parselength- the number of bytes to parsecharset- specifyCharsetto parsetype- specify theTypeto be converted- Throws:
IndexOutOfBoundsException- If the offset and the length arguments index characters outside the bounds of the bytes array
-
parseObject
static <T> T parseObject(byte[] bytes, int offset, int length, Charset charset, Class<T> type, JSONReader.Feature... features) Parses the JSON byte array of the specifiedCharsetinto a Java Object- Parameters:
bytes- JSON byte array to parseoffset- the index of the first byte to parselength- the number of bytes to parsecharset- specifyCharsetto parsetype- specify theClassto be convertedfeatures- features to be enabled in parsing- Throws:
IndexOutOfBoundsException- If the offset and the length arguments index characters outside the bounds of the bytes array
-
parseObject
static <T> void parseObject(InputStream input, Type type, Consumer<T> consumer, JSONReader.Feature... features) ParseInputStreaminto a Java object with specifiedJSONReader.Features enabled and consume it- Parameters:
input- the JSONInputStreamto be parsedtype- specify theTypeto be convertedconsumer- the consumer of the parsing result objectfeatures- features to be enabled in parsing- Throws:
JSONException- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs- Since:
- 2.0.2
- See Also:
-
parseObject
static <T> void parseObject(InputStream input, Charset charset, char delimiter, Type type, Consumer<T> consumer, JSONReader.Feature... features) ParseInputStreaminto a Java object with specifiedJSONReader.Features enabled and consume it- Parameters:
input- the JSONInputStreamto be parsedcharset- specifyCharsetto parsedelimiter- specify the delimitertype- specify theTypeto be convertedconsumer- the consumer of the parsing result objectfeatures- features to be enabled in parsing- Throws:
JSONException- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs- Since:
- 2.0.2
-
parseObject
ParseReaderinto a Java object with specifiedJSONReader.Features enabled and consume it- Parameters:
input- the JSONReaderto be parseddelimiter- specify the delimitertype- specify theTypeto be convertedconsumer- the consumer of the parsing result object- Throws:
JSONException- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs- Since:
- 2.0.2
-
parseArray
- Parameters:
text- the JSONStringto be parsed
-
parseArray
- Parameters:
bytes- the JSONStringto be parsed
-
parseArray
-
parseArray
- Parameters:
chars- the JSONStringto be parsed
-
parseArray
- Parameters:
text- the JSONStringto be parsedfeatures- features to be enabled in parsing
-
parseArray
Parse JSONInputStreamintoJSONArray- Parameters:
url- the JSONURLto be parsedfeatures- features to be enabled in parsing
-
parseArray
Parse JSONInputStreamintoJSONArray- Parameters:
in- the JSONInputStreamto be parsedfeatures- features to be enabled in parsing
-
parseArray
-
parseArray
-
parseArray
-
parseArray
-
parseArray
-
parseArray
-
parseArray
Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theTypeto be convertedfeatures- features to be enabled in parsing
-
parseArray
Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabled- Parameters:
bytes- UTF8 encoded JSON byte array to parsetype- specify theClassto be convertedfeatures- features to be enabled in parsing
-
parseArray
static <T> List<T> parseArray(byte[] bytes, int offset, int length, Charset charset, Class<T> type, JSONReader.Feature... features) Parse UTF8 encoded JSON byte array intoListwith specifiedJSONReader.Features enabled -
toJSONString
Serialize Java Object to JSONString- Parameters:
object- Java Object to be serialized into JSONString
-
toJSONString
Serialize Java Object to JSONString- Parameters:
object- Java Object to be serialized into JSONStringcontext-
-
toJSONString
Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringfeatures- features to be enabled in serialization
-
toJSONString
Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringfilter- specify a filter to use in serializationfeatures- features to be enabled in serialization
-
toJSONString
Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization
-
toJSONString
Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringformat- the specified date formatfeatures- features to be enabled in serialization
-
toJSONString
static String toJSONString(Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSONStringwith specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSONStringformat- the specified date formatfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization
-
toJSONBytes
Serialize Java Object to JSON byte array- Parameters:
object- Java Object to be serialized into JSON byte array
-
toJSONBytes
Serialize Java Object to JSON byte array- Parameters:
object- Java Object to be serialized into JSON byte arrayfilters- specifies the filter to use in serialization
-
toJSONBytes
Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSON byte arrayfeatures- features to be enabled in serialization
-
toJSONBytes
Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSON byte arrayfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization
-
toJSONBytes
static byte[] toJSONBytes(Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON byte array with specifiedJSONReader.Features enabled- Parameters:
object- Java Object to be serialized into JSON byte arrayformat- the specified date formatfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization
-
writeTo
Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabled- Parameters:
out-OutputStreamto be writtenobject- Java Object to be serialized into JSONfeatures- features to be enabled in serialization- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed
-
writeTo
static int writeTo(OutputStream out, Object object, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabled- Parameters:
out-OutputStreamto be writtenobject- Java Object to be serialized into JSONfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed
-
writeTo
static int writeTo(OutputStream out, Object object, String format, Filter[] filters, JSONWriter.Feature... features) Serialize Java Object to JSON and write toOutputStreamwith specifiedJSONReader.Features enabled- Parameters:
out-OutputStreamto be writtenobject- Java Object to be serialized into JSONformat- the specified date formatfilters- specifies the filter to use in serializationfeatures- features to be enabled in serialization- Throws:
JSONException- if an I/O error occurs. In particular, aJSONExceptionmay be thrown if the output stream has been closed
-
isValid
Verify theStringis JSON- Parameters:
text- theStringto validate- Returns:
trueorfalse
-
isValid
static boolean isValid(char[] chars) Verify the char array is JSON- Parameters:
chars- theStringto validate- Returns:
trueorfalse
-
isValidObject
Verify theStringis JSON Object- Parameters:
text- theStringto validate- Returns:
trueorfalse
-
isValidObject
static boolean isValidObject(byte[] bytes) Verify the byte array is JSON Object- Parameters:
bytes- the byte array to validate- Returns:
trueorfalse
-
isValidArray
Verify theStringis JSON Array- Parameters:
text- theStringto validate- Returns:
trueorfalse
-
isValid
static boolean isValid(byte[] bytes) Verify the byte array is JSON Object- Parameters:
bytes- the byte array to validate- Returns:
trueorfalse
-
isValidArray
static boolean isValidArray(byte[] bytes) Verify the byte array is JSON Array- Parameters:
bytes- the byte array to validate- Returns:
trueorfalse
-
isValid
Verify the byte array is JSON Object- Parameters:
bytes- the byte array to validateoffset- the index of the first byte to validatelength- the number of bytes to validatecharset- specifyCharsetto validate- Returns:
trueorfalse
-
toJSON
Convert Java object order toJSONArrayorJSONObject- Parameters:
object- Java Object to be converted- Returns:
- Java Object
-
toJSON
Convert Java object order toJSONArrayorJSONObject- Parameters:
object- Java Object to be converted- Returns:
- Java Object
-
to
Convert the Object to the target type- Parameters:
clazz- converted goal classobject- Java Object to be converted- Since:
- 2.0.4
-
toJavaObject
Deprecated.since 2.0.4, please useto(Class, Object)Convert the Object to the target type- Parameters:
object- Java Object to be convertedclazz- converted goal class
-
mixIn
- Since:
- 2.0.2
-
register
- Since:
- 2.0.2
- See Also:
-
registerIfAbsent
-
register
Register anObjectReaderModulein defaultObjectReaderProvider -
register
Register anObjectWriterModulein defaultObjectWriterProvider -
register
- Since:
- 2.0.2
- See Also:
-
registerIfAbsent
-
register
Register ObjectWriterFilter- Parameters:
type-filter-- Since:
- 2.0.19
-
config
Enable the specified features in default reader- Parameters:
features- the specified features to be used- Since:
- 2.0.6
-
config
Enable or disable the specified features in default reader- Parameters:
feature- the specified feature to be usedstate- enable this feature if and only ifstateistrue, disable otherwise- Since:
- 2.0.6
-
isEnabled
Check if the default reader enables the specified feature- Parameters:
feature- the specified feature- Since:
- 2.0.6
-
config
Enable the specified features in default writer- Parameters:
features- the specified features to be used- Since:
- 2.0.6
-
config
Enable or disable the specified features in default writer- Parameters:
feature- the specified feature to be usedstate- enable this feature if and only ifstateistrue, disable otherwise- Since:
- 2.0.6
-
isEnabled
Check if the default writer enables the specified feature- Parameters:
feature- the specified feature- Since:
- 2.0.6
-
copy
use ObjectWriter and ObjectReader copy java object- Parameters:
object- the object to be copyfeatures- the specified features- Since:
- 2.0.12
-
copyTo
use ObjectWriter and ObjectReader copy java object- Parameters:
object- the object to be copytargetClass- target classfeatures- the specified features- Since:
- 2.0.16
-
to(Class, Object)