Package com.alibaba.fastjson
Class JSON
- java.lang.Object
-
- com.alibaba.fastjson.JSON
-
- All Implemented Interfaces:
JSONAware
- Direct Known Subclasses:
JSONArray,JSONObject
public abstract class JSON extends Object implements JSONAware
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_GENERATE_FEATUREstatic intDEFAULT_PARSER_FEATUREstatic StringDEFAULT_TYPE_KEYstatic LocaledefaultLocalestatic TimeZonedefaultTimeZonestatic StringDEFFAULT_DATE_FORMATstatic StringVERSION
-
Constructor Summary
Constructors Constructor Description JSON()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static voidaddMixInAnnotations(Type target, Type mixinSource)static voidclearMixInAnnotations()static voidconfigFilter(com.alibaba.fastjson2.JSONWriter.Context context, SerializeFilter filter)static com.alibaba.fastjson2.JSONReader.ContextcreateReadContext(int featuresValue, Feature... features)static com.alibaba.fastjson2.JSONReader.ContextcreateReadContext(com.alibaba.fastjson2.reader.ObjectReaderProvider provider, int featuresValue, Feature... features)static com.alibaba.fastjson2.JSONWriter.ContextcreateWriteContext(SerializeConfig config, int featuresValue, SerializerFeature... features)static TypegetMixInAnnotations(Type target)static booleanisValid(String str)static booleanisValidArray(String str)static booleanisValidObject(String str)static Objectparse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features)static Objectparse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features)static Objectparse(byte[] utf8Bytes, Feature... features)static Objectparse(String str)static Objectparse(String text, int features)static Objectparse(String str, Feature... features)static Objectparse(String str, ParserConfig config)static Objectparse(String str, ParserConfig config, int features)static Objectparse(String str, ParserConfig config, Feature... features)static JSONArrayparseArray(String str)static JSONArrayparseArray(String str, Feature... features)static <T> List<T>parseArray(String text, Class<T> type)static <T> List<T>parseArray(String text, Class<T> type, Feature... features)static <T> List<T>parseArray(String text, Class<T> clazz, ParserConfig config)static List<Object>parseArray(String text, Type[] types)static <T> TparseObject(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Type clazz, Feature... features)static <T> TparseObject(byte[] input, int off, int len, Charset charset, Type clazz, Feature... features)static <T> TparseObject(byte[] bytes, int offset, int len, Charset charset, Type objectType, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)static <T> JSONObjectparseObject(byte[] jsonBytes, Feature... features)static <T> TparseObject(byte[] jsonBytes, Class<T> type, Feature... features)static <T> TparseObject(byte[] jsonBytes, Type type, Feature... features)static <T> TparseObject(byte[] jsonBytes, Type type, SerializeFilter filter, Feature... features)static <T> TparseObject(byte[] jsonBytes, Type type, com.alibaba.fastjson2.JSONReader.Context context)static <T> TparseObject(byte[] bytes, Charset charset, Type objectClass, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)static <T> TparseObject(char[] str, int length, Type objectType, Feature... features)static <T> TparseObject(char[] str, Class<T> objectClass, Feature... features)static <T> TparseObject(InputStream is, Class<T> objectType, Feature... features)static <T> TparseObject(InputStream is, Type objectType, Feature... features)static <T> TparseObject(InputStream is, Charset charset, Type objectType, Feature... features)static <T> TparseObject(InputStream is, Charset charset, Type objectType, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)static <T> TparseObject(InputStream is, Charset charset, Type type, ParserConfig config, Feature... features)static JSONObjectparseObject(String str)static JSONObjectparseObject(String text, Feature... features)static <T> TparseObject(String str, TypeReference<T> typeReference, Feature... features)static <T> TparseObject(String str, Class<T> objectClass)static <T> TparseObject(String str, Class<T> objectClass, ParseProcess processor, Feature... features)static <T> TparseObject(String str, Class<T> objectType, Feature... features)static <T> TparseObject(String input, Type clazz, int featureValues, Feature... features)static <T> TparseObject(String str, Type objectType, ParseProcess processor, Feature... features)static <T> TparseObject(String str, Type objectType, Feature... features)static <T> TparseObject(String input, Type clazz, ParserConfig config, int featureValues, Feature... features)static <T> TparseObject(String str, Type objectClass, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)static <T> TparseObject(String str, Type objectType, ParserConfig config, Feature... features)static voidremoveMixInAnnotations(Type target)static <T> TtoJavaObject(JSON json, Class<T> clazz)<T> TtoJavaObject(TypeReference<T> typeReference)abstract <T> TtoJavaObject(Class<T> objectClass)abstract <T> TtoJavaObject(Type type)static ObjecttoJSON(Object javaObject)static ObjecttoJSON(Object javaObject, ParserConfig config)static ObjecttoJSON(Object javaObject, SerializeConfig config)static byte[]toJSONBytes(Object object)static byte[]toJSONBytes(Object object, int defaultFeatures, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeConfig config, int defaultFeatures, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeConfig config, SerializeFilter[] filters, int defaultFeatures, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeConfig config, SerializeFilter filter, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeConfig config, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeFilter filter)static byte[]toJSONBytes(Object object, SerializeFilter... filters)static byte[]toJSONBytes(Object object, SerializeFilter[] filters, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializeFilter filter, SerializerFeature... features)static byte[]toJSONBytes(Object object, SerializerFeature... features)static byte[]toJSONBytes(Charset charset, Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)StringtoJSONString()static StringtoJSONString(Object object)static StringtoJSONString(Object object, boolean prettyFormat)static StringtoJSONString(Object object, int defaultFeatures, SerializerFeature... features)static StringtoJSONString(Object object, SerializeConfig config, SerializeFilter[] filters, SerializerFeature... features)static StringtoJSONString(Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)static StringtoJSONString(Object object, SerializeConfig config, SerializeFilter filter, SerializerFeature... features)static StringtoJSONString(Object object, SerializeConfig config, SerializerFeature... features)static StringtoJSONString(Object object, SerializeFilter[] filters, SerializerFeature... features)static StringtoJSONString(Object object, SerializeFilter filter0, SerializeFilter filter1, SerializeFilter... filters)static StringtoJSONString(Object object, SerializeFilter filter, SerializerFeature... features)static StringtoJSONString(Object object, SerializerFeature... features)static StringtoJSONStringWithDateFormat(Object object, String dateFormat, SerializerFeature... features)static StringtoJSONStringZ(Object object, SerializeConfig mapping, SerializerFeature... features)StringtoString(SerializerFeature... features)static intwriteJSONString(OutputStream os, Object object, int defaultFeatures, SerializerFeature... features)static intwriteJSONString(OutputStream os, Object object, SerializeFilter[] filters)static intwriteJSONString(OutputStream os, Object object, SerializeFilter[] filters, SerializerFeature... features)static intwriteJSONString(OutputStream os, Object object, SerializerFeature... features)static intwriteJSONString(OutputStream os, Object object, String dateFormat, SerializeFilter[] filters, SerializerFeature... features)static intwriteJSONString(OutputStream os, Charset charset, Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)static intwriteJSONString(OutputStream os, Charset charset, Object object, SerializerFeature... features)static voidwriteJSONString(Writer writer, Object object, int defaultFeatures, SerializerFeature... features)static voidwriteJSONString(Writer writer, Object object, SerializerFeature... features)voidwriteJSONString(Appendable appendable)
-
-
-
Field Detail
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
defaultTimeZone
public static TimeZone defaultTimeZone
-
defaultLocale
public static Locale defaultLocale
-
DEFAULT_TYPE_KEY
public static String DEFAULT_TYPE_KEY
-
DEFFAULT_DATE_FORMAT
public static String DEFFAULT_DATE_FORMAT
-
DEFAULT_PARSER_FEATURE
public static int DEFAULT_PARSER_FEATURE
-
DEFAULT_GENERATE_FEATURE
public static int DEFAULT_GENERATE_FEATURE
-
-
Method Detail
-
createReadContext
public static com.alibaba.fastjson2.JSONReader.Context createReadContext(int featuresValue, Feature... features)
-
createReadContext
public static com.alibaba.fastjson2.JSONReader.Context createReadContext(com.alibaba.fastjson2.reader.ObjectReaderProvider provider, int featuresValue, Feature... features)
-
parseObject
public static JSONObject parseObject(String str)
-
parseObject
public static JSONObject parseObject(String text, Feature... features)
-
parseObject
public static <T> T parseObject(byte[] bytes, Charset charset, Type objectClass, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)
-
parseObject
public static <T> T parseObject(byte[] bytes, int offset, int len, Charset charset, Type objectType, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)
-
parseObject
public static <T> T parseObject(char[] str, int length, Type objectType, Feature... features)
-
parseObject
public static <T> T parseObject(String str, Type objectClass, ParserConfig config, ParseProcess processor, int featureValues, Feature... features)
-
parseObject
public static <T> T parseObject(String input, Type clazz, ParserConfig config, int featureValues, Feature... features)
-
parseObject
public static <T> T parseObject(String str, Type objectType, ParseProcess processor, Feature... features)
-
parseObject
public static <T> T parseObject(String str, Class<T> objectClass, ParseProcess processor, Feature... features)
-
parseObject
public static <T> T parseObject(String str, TypeReference<T> typeReference, Feature... features)
-
parseObject
public static <T> T parseObject(String input, Type clazz, int featureValues, Feature... features)
-
parseObject
public static <T> T parseObject(String str, Type objectType, ParserConfig config, Feature... features)
- Since:
- 1.2.11
-
parseObject
public static <T> T parseObject(InputStream is, Type objectType, Feature... features) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(InputStream is, Class<T> objectType, Feature... features) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(InputStream is, Charset charset, Type objectType, ParserConfig config, ParseProcess processor, int featureValues, Feature... features) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(InputStream is, Charset charset, Type type, ParserConfig config, Feature... features) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(InputStream is, Charset charset, Type objectType, Feature... features) throws IOException
- Throws:
IOException
-
parseObject
public static <T> JSONObject parseObject(byte[] jsonBytes, Feature... features)
- Since:
- 2.0.7
-
parseObject
public static <T> T parseObject(byte[] jsonBytes, Type type, com.alibaba.fastjson2.JSONReader.Context context)
-
parseObject
public static <T> T parseObject(byte[] jsonBytes, Type type, SerializeFilter filter, Feature... features)
-
parse
public static Object parse(String str, ParserConfig config, Feature... features)
-
parse
public static Object parse(String str, ParserConfig config)
-
parse
public static Object parse(String str, ParserConfig config, int features)
-
parse
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features)
-
parse
public static Object parse(byte[] input, int off, int len, CharsetDecoder charsetDecoder, int features)
-
parseObject
public static <T> T parseObject(byte[] input, int off, int len, CharsetDecoder charsetDecoder, Type clazz, Feature... features)
-
parseObject
public static <T> T parseObject(byte[] input, int off, int len, Charset charset, Type clazz, Feature... features)
-
createWriteContext
public static com.alibaba.fastjson2.JSONWriter.Context createWriteContext(SerializeConfig config, int featuresValue, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeConfig config, SerializeFilter[] filters, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeFilter[] filters, SerializerFeature... features)
-
configFilter
public static void configFilter(com.alibaba.fastjson2.JSONWriter.Context context, SerializeFilter filter)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeConfig config, SerializeFilter[] filters, int defaultFeatures, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeConfig config, SerializeFilter filter, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Charset charset, Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeFilter[] filters, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeConfig config, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeFilter filter0, SerializeFilter filter1, SerializeFilter... filters)
-
toJSONString
public static String toJSONString(Object object, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeFilter... filters)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, int defaultFeatures, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeFilter filter)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeFilter filter, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializerFeature... features)
-
toJSONBytes
public static byte[] toJSONBytes(Object object, SerializeConfig config, int defaultFeatures, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeConfig config, SerializerFeature... features)
-
toJSONStringZ
public static String toJSONStringZ(Object object, SerializeConfig mapping, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeConfig config, SerializeFilter filter, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, SerializeFilter filter, SerializerFeature... features)
-
toJSONString
public static String toJSONString(Object object, int defaultFeatures, SerializerFeature... features)
-
toJSONStringWithDateFormat
public static String toJSONStringWithDateFormat(Object object, String dateFormat, SerializerFeature... features)
-
writeJSONString
public static final int writeJSONString(OutputStream os, Object object, SerializerFeature... features) throws IOException
- Throws:
IOException
-
writeJSONString
public static final int writeJSONString(OutputStream os, Object object, SerializeFilter[] filters) throws IOException
- Throws:
IOException
-
writeJSONString
public static final int writeJSONString(OutputStream os, Charset charset, Object object, SerializerFeature... features) throws IOException
- Throws:
IOException
-
writeJSONString
public static void writeJSONString(Writer writer, Object object, SerializerFeature... features)
-
writeJSONString
public static void writeJSONString(Writer writer, Object object, int defaultFeatures, SerializerFeature... features)
-
writeJSONString
public static final int writeJSONString(OutputStream os, Object object, int defaultFeatures, SerializerFeature... features) throws IOException
- Throws:
IOException
-
writeJSONString
public static final int writeJSONString(OutputStream os, Charset charset, Object object, SerializeConfig config, SerializeFilter[] filters, String dateFormat, int defaultFeatures, SerializerFeature... features) throws IOException
- Throws:
IOException
-
writeJSONString
public static final int writeJSONString(OutputStream os, Object object, SerializeFilter[] filters, SerializerFeature... features) throws IOException
- Throws:
IOException
-
writeJSONString
public static final int writeJSONString(OutputStream os, Object object, String dateFormat, SerializeFilter[] filters, SerializerFeature... features) throws IOException
- Throws:
IOException
-
parseArray
public static <T> List<T> parseArray(String text, Class<T> clazz, ParserConfig config)
-
isValid
public static boolean isValid(String str)
-
isValidArray
public static boolean isValidArray(String str)
-
isValidObject
public static boolean isValidObject(String str)
-
toJavaObject
public abstract <T> T toJavaObject(Class<T> objectClass)
-
toJavaObject
public abstract <T> T toJavaObject(Type type)
-
toJavaObject
public <T> T toJavaObject(TypeReference<T> typeReference)
-
toJSON
public static Object toJSON(Object javaObject, SerializeConfig config)
-
toJSON
public static Object toJSON(Object javaObject, ParserConfig config)
-
removeMixInAnnotations
public static void removeMixInAnnotations(Type target)
-
clearMixInAnnotations
public static void clearMixInAnnotations()
-
toJSONString
public String toJSONString()
- Specified by:
toJSONStringin interfaceJSONAware- Returns:
- JSON text
-
toString
public String toString(SerializerFeature... features)
-
writeJSONString
public void writeJSONString(Appendable appendable)
-
-