public interface JSON
Example usage:
// 1. Parse JSON string to Object
String jsonString = "{\"id\":1,\"name\":\"John\",\"age\":30}";
User user = JSON.parseObject(jsonString, User.class);
// 2. Serialize Object to JSON string
User user = new User(1L, "John", 30, new Date(), Arrays.asList("reading", "swimming"));
String jsonString = JSON.toJSONString(user);
// 3. Parse JSON string to JSONObject
JSONObject jsonObject = JSON.parseObject(jsonString);
// 4. Parse JSON string to JSONArray
String jsonArrayString = "[{\"id\":1,\"name\":\"John\"},{\"id\":2,\"name\":\"Jane\"}]";
JSONArray jsonArray = JSON.parseArray(jsonArrayString);
// 5. Parse JSON string to List
List<User> userList = JSON.parseArray(jsonArrayString, User.class);
// 6. Parse JSON with features
User user = JSON.parseObject(jsonString, User.class, JSONReader.Feature.FieldBased);
// 7. Serialize with features
String jsonString = JSON.toJSONString(user, JSONWriter.Feature.PrettyFormat);
// 8. Parse from byte array
byte[] bytes = jsonString.getBytes(StandardCharsets.UTF_8);
User user = JSON.parseObject(bytes, User.class);
// 9. Serialize to byte array
byte[] bytes = JSON.toJSONBytes(user);
// 10. Validate JSON string
boolean valid = JSON.isValid(jsonString);
For more advanced usage:
// 1. Working with generic types
String jsonString = "{\"users\":[{\"id\":1,\"name\":\"John\"}]}";
TypeReference<Map<String, List<User>>> typeReference = new TypeReference<Map<String, List<User>>>() {};
Map<String, List<User>> map = JSON.parseObject(jsonString, typeReference);
// 2. Working with filters
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
filter.getExcludes().add("id");
String jsonString = JSON.toJSONString(user, filter);
// 3. Working with date format
String jsonString = JSON.toJSONString(user, "yyyy-MM-dd HH:mm:ss");
// 4. Working with custom context
JSONReader.Context readerContext = JSONFactory.createReadContext();
readerContext.setDateFormat("yyyy-MM-dd");
User user = JSON.parseObject(jsonString, User.class, readerContext);
// 5. Streaming parsing
try (InputStream inputStream = new FileInputStream("data.json")) {
JSON.parseObject(inputStream, User.class, System.out::println);
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
VERSION
fastjson2 version name
|
| Modifier and Type | Method and Description |
|---|---|
static void |
config(JSONReader.Feature... features)
Enable the specified features in default reader
|
static void |
config(JSONReader.Feature feature,
boolean state)
Enable or disable the specified features in default reader
|
static void |
config(JSONWriter.Feature... features)
Enable the specified features in default writer
|
static void |
config(JSONWriter.Feature feature,
boolean state)
Enable or disable the specified features in default writer
|
static void |
configEnumAsJavaBean(java.lang.Class<? extends java.lang.Enum>... enumClasses)
Configure the Enum classes as a JavaBean
|
static void |
configReaderDateFormat(java.lang.String dateFormat)
Config default reader dateFormat
|
static void |
configReaderZoneId(java.time.ZoneId zoneId)
Config default reader zoneId
|
static void |
configWriterDateFormat(java.lang.String dateFormat)
Config default writer dateFormat
|
static void |
configWriterZoneId(java.time.ZoneId zoneId)
Config default writer zoneId
|
static <T> T |
copy(T object,
JSONWriter.Feature... features)
Builds a new
T using the properties of the specified object |
static <T> T |
copyTo(java.lang.Object object,
java.lang.Class<T> targetClass,
JSONWriter.Feature... features)
Builds a new instance of targetClass using the properties of the specified object
|
static boolean |
isEnabled(JSONReader.Feature feature)
Check if the default reader enables the specified feature
|
static boolean |
isEnabled(JSONWriter.Feature feature)
Check if the default writer enables the specified feature
|
static boolean |
isValid(byte[] bytes)
Verify that the json byte array is legal json text
|
static boolean |
isValid(byte[] bytes,
java.nio.charset.Charset charset)
Verify that the json byte array is legal json text
|
static boolean |
isValid(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset)
Verify that the json byte array is legal json text
|
static boolean |
isValid(char[] chars)
Verify that the json char array is legal json text
|
static boolean |
isValid(java.lang.String text)
Verify that the json string is legal json text
|
static boolean |
isValid(java.lang.String text,
JSONReader.Feature... features)
Verify that the json string is legal json text
|
static boolean |
isValidArray(byte[] bytes)
Verify that the json byte array is a legal JsonArray
|
static boolean |
isValidArray(java.lang.String text)
Verify the
String is JSON Array |
static boolean |
isValidObject(byte[] bytes)
Verify that the json byte array is a legal JsonObject
|
static boolean |
isValidObject(java.lang.String text)
Verify that the json string is a legal JsonObject
|
static void |
mixIn(java.lang.Class<?> target,
java.lang.Class<?> mixinSource)
Mixes in the properties of the mixinSource class into the target class
|
static java.lang.Object |
parse(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
JSONReader.Context context)
Parses the json byte array as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(byte[] bytes,
JSONReader.Context context)
Parses the json byte array as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(byte[] bytes,
JSONReader.Feature... features)
Parses the json byte array as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(char[] chars,
JSONReader.Context context)
Parses the json char array as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(char[] chars,
JSONReader.Feature... features)
Parses the json char array as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.io.InputStream in,
java.nio.charset.Charset charset)
Parses the json stream as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.io.InputStream in,
java.nio.charset.Charset charset,
JSONReader.Context context)
Parses the json stream as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.io.InputStream in,
JSONReader.Context context)
Parses the json stream as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.io.InputStream in,
JSONReader.Feature... features)
Parses the json stream as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.lang.String text)
Parses the json string as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.lang.String text,
int offset,
int length,
JSONReader.Feature... features)
Parses the json string as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.lang.String text,
JSONReader.Context context)
Parses the json string as a
JSONArray or JSONObject. |
static java.lang.Object |
parse(java.lang.String text,
JSONReader.Feature... features)
Parses the json string as a
JSONArray or JSONObject. |
static JSONArray |
parseArray(byte[] bytes)
Parses the json byte array as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(byte[] bytes,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parses the json byte array as a list of
T. |
static JSONArray |
parseArray(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset)
Parses the json byte array as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parses the json byte array as a list of
T. |
static <T> java.util.List<T> |
parseArray(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json byte array as a list of
T. |
static JSONArray |
parseArray(char[] chars)
Parses the json char array as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(char[] chars,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parses the json char array as a list of
T. |
static JSONArray |
parseArray(java.io.InputStream in,
java.nio.charset.Charset charset,
JSONReader.Context context)
Parses the json stream as a
JSONArray. |
static JSONArray |
parseArray(java.io.InputStream in,
JSONReader.Feature... features)
Parses the json stream as a
JSONArray. |
static JSONArray |
parseArray(java.io.Reader input,
JSONReader.Feature... features)
Parses the json reader as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(java.io.Reader input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json reader as a list of
T. |
static JSONArray |
parseArray(java.lang.String text)
Parses the json string as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.Class<T> type)
Parses the json string as a list of
T. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parses the json string as a list of
T. |
static JSONArray |
parseArray(java.lang.String text,
JSONReader.Feature... features)
Parses the json string as a
JSONArray. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.reflect.Type... types)
Parses the json string as a list of
T. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.reflect.Type type)
Parses the json string as a list of
T. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.reflect.Type[] types,
JSONReader.Feature... features)
Parses the json string as a list of
T. |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json string as a list of
T. |
static JSONArray |
parseArray(java.net.URL url,
JSONReader.Feature... features)
Parses the json stream of the url as a
JSONArray. |
static JSONObject |
parseObject(byte[] bytes)
Parses the json byte array as a
JSONObject. |
static <T> T |
parseObject(byte[] bytes,
java.lang.Class<T> clazz)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.Class<T> clazz,
Filter filter,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.Class<T> clazz,
JSONReader.Context context)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static JSONObject |
parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
JSONReader.Feature... features)
Parses the json byte array as a
JSONObject. |
static <T> T |
parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.reflect.Type type)
Parses the json byte array as
T. |
static JSONObject |
parseObject(byte[] bytes,
int offset,
int length,
JSONReader.Feature... features)
Parses the json byte array as a
JSONObject. |
static <T> T |
parseObject(byte[] bytes,
int offset,
int length,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static JSONObject |
parseObject(byte[] bytes,
JSONReader.Feature... features)
Parses the json byte array as a
JSONObject. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type,
Filter filter,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Context context)
Parses the json string as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type,
java.lang.String format,
Filter[] filters,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(byte[] bytes,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static <T> T |
parseObject(java.nio.ByteBuffer buffer,
java.lang.Class<T> objectClass)
Parses the json byte buffer as a
T. |
static JSONObject |
parseObject(char[] chars)
Parses the json char array as a
JSONObject. |
static <T> T |
parseObject(char[] chars,
java.lang.Class<T> clazz)
Parses the json char array as
T. |
static <T> T |
parseObject(char[] chars,
java.lang.Class<T> objectClass,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static JSONObject |
parseObject(char[] chars,
int offset,
int length,
JSONReader.Feature... features)
Parses the json chars array as a
JSONObject. |
static <T> T |
parseObject(char[] chars,
int offset,
int length,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json char array as
T. |
static <T> T |
parseObject(char[] chars,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json byte array as
T. |
static JSONObject |
parseObject(java.io.InputStream in,
java.nio.charset.Charset charset)
Parses the json stream as a
JSONObject. |
static <T> void |
parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
char delimiter,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer,
JSONReader.Feature... features)
Parses the json stream through the specified delimiter as
T objects and call the specified consumer to consume it |
static <T> T |
parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Context context)
Parses the json stream as a
T. |
static JSONObject |
parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
JSONReader.Context context)
Parses the json stream as a
JSONObject. |
static <T> T |
parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.reflect.Type type,
JSONReader.Context context)
Parses the json stream as a
T. |
static <T> T |
parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json stream as a
T. |
static JSONObject |
parseObject(java.io.InputStream input,
JSONReader.Feature... features)
Parses the json stream as a
JSONObject. |
static <T> void |
parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer,
JSONReader.Feature... features)
Parses the json stream through the specified delimiter as
T objects and call the specified consumer to consume it |
static <T> T |
parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json stream as a
T. |
static <T> T |
parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
Parses the json stream as a
T. |
static <T> void |
parseObject(java.io.Reader input,
char delimiter,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer)
Parses the json reader through the specified delimiter as
T objects and call the specified consumer to consume it |
static JSONObject |
parseObject(java.io.Reader input,
JSONReader.Feature... features)
Parses the json reader as a
JSONObject. |
static <T> T |
parseObject(java.io.Reader input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json reader as a
T. |
static JSONObject |
parseObject(java.lang.String text)
Parses the json string as a
JSONObject. |
static <T> T |
parseObject(java.lang.String text,
java.lang.Class<T> clazz)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.Class<T> clazz,
Filter filter,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.Class<T> clazz,
JSONReader.Context context)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.Class<T> clazz,
java.lang.String format,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
int offset,
int length,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
Parses the json string as
T. |
static JSONObject |
parseObject(java.lang.String text,
int offset,
int length,
JSONReader.Context context)
Parses the json string as a
JSONObject. |
static JSONObject |
parseObject(java.lang.String text,
int offset,
int length,
JSONReader.Feature... features)
Parses the json string as a
JSONObject. |
static JSONObject |
parseObject(java.lang.String text,
JSONReader.Context context)
Parses the json string as a
JSONObject. |
static JSONObject |
parseObject(java.lang.String text,
JSONReader.Feature... features)
Parses the json string as a
JSONObject. |
static <T extends java.util.Map<java.lang.String,java.lang.Object>> |
parseObject(java.lang.String text,
MapMultiValueType<T> type)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type... types)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type,
Filter filter,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Context context)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
TypeReference<T> typeReference,
Filter filter,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
TypeReference<T> typeReference,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type,
java.lang.String format,
Filter[] filters,
JSONReader.Feature... features)
Parses the json string as
T. |
static <T> T |
parseObject(java.lang.String text,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
Parses the json string as
T. |
static JSONObject |
parseObject(java.net.URL url)
Parses the json stream of the url as a
JSONObject. |
static <T> T |
parseObject(java.net.URL url,
java.lang.Class<T> objectClass,
JSONReader.Feature... features)
Parses the json stream of the url as
T. |
static <T> T |
parseObject(java.net.URL url,
java.util.function.Function<JSONObject,T> function,
JSONReader.Feature... features)
Parses the json stream of the url as a
JSONObject and call the function
to convert it to T. |
static <T> T |
parseObject(java.net.URL url,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Parses the json stream of the url as
T. |
static void |
register(java.lang.Class type,
Filter filter)
Register ObjectWriterFilter
|
static boolean |
register(ObjectReaderModule objectReaderModule)
Register an
ObjectReaderModule in default ObjectReaderProvider |
static boolean |
register(ObjectWriterModule objectWriterModule)
Register an
ObjectWriterModule in default ObjectWriterProvider |
static ObjectReader<?> |
register(java.lang.reflect.Type type,
ObjectReader<?> objectReader)
|
static ObjectReader<?> |
register(java.lang.reflect.Type type,
ObjectReader<?> objectReader,
boolean fieldBased)
|
static ObjectWriter<?> |
register(java.lang.reflect.Type type,
ObjectWriter<?> objectWriter)
|
static ObjectWriter<?> |
register(java.lang.reflect.Type type,
ObjectWriter<?> objectWriter,
boolean fieldBased)
|
static ObjectReader<?> |
registerIfAbsent(java.lang.reflect.Type type,
ObjectReader<?> objectReader)
|
static ObjectReader<?> |
registerIfAbsent(java.lang.reflect.Type type,
ObjectReader<?> objectReader,
boolean fieldBased)
|
static ObjectWriter<?> |
registerIfAbsent(java.lang.reflect.Type type,
ObjectWriter<?> objectWriter)
|
static ObjectWriter<?> |
registerIfAbsent(java.lang.reflect.Type type,
ObjectWriter<?> objectWriter,
boolean fieldBased)
|
static void |
registerSeeAlsoSubType(java.lang.Class subTypeClass)
Register a see-also sub type
|
static void |
registerSeeAlsoSubType(java.lang.Class subTypeClass,
java.lang.String subTypeClassName)
Register a see-also sub type with a specific class name
|
static <T> T |
to(java.lang.Class<T> clazz,
java.lang.Object object)
Converts the specified object to an object of the specified goal type
|
static <T> T |
toJavaObject(java.lang.Object object,
java.lang.Class<T> clazz)
Deprecated.
since 2.0.4, please use
to(Class, Object) |
static java.lang.Object |
toJSON(java.lang.Object object)
Converts the specified object to a
JSONArray or
JSONObject. |
static java.lang.Object |
toJSON(java.lang.Object object,
JSONWriter.Feature... features)
Converts the specified object to a
JSONArray or
JSONObject. |
static byte[] |
toJSONBytes(java.lang.Object object)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
java.nio.charset.Charset charset,
JSONWriter.Context context)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
java.nio.charset.Charset charset,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
Filter... filters)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array
|
static byte[] |
toJSONBytes(java.lang.Object object,
java.lang.String format,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array
|
static java.lang.String |
toJSONString(java.lang.Object object)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
Filter filter,
JSONWriter.Feature... features)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
JSONWriter.Context context)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
JSONWriter.Feature... features)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json string
|
static java.lang.String |
toJSONString(java.lang.Object object,
java.lang.String format,
JSONWriter.Feature... features)
Serializes the specified object to the json string
|
static int |
writeTo(java.io.OutputStream out,
java.lang.Object object)
Serializes the specified object to the json byte array and write it to
OutputStream |
static int |
writeTo(java.io.OutputStream out,
java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array and write it to
OutputStream |
static int |
writeTo(java.io.OutputStream out,
java.lang.Object object,
JSONWriter.Context context)
Serializes the specified object to the json byte array and write it to
OutputStream |
static int |
writeTo(java.io.OutputStream out,
java.lang.Object object,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array and write it to
OutputStream |
static int |
writeTo(java.io.OutputStream out,
java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
Serializes the specified object to the json byte array and write it to
OutputStream |
static final java.lang.String VERSION
static java.lang.Object parse(java.lang.String text)
JSONArray or JSONObject.
Returns null if received String is null or empty.text - the specified text to be parsedJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(java.lang.String text,
JSONReader.Feature... features)
JSONArray or JSONObject.
Returns null if received String is null or empty.text - the specified text to be parsedfeatures - the specified features is applied to parsingJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(java.lang.String text,
int offset,
int length,
JSONReader.Feature... features)
JSONArray or JSONObject.
Returns null if received String is null or empty or length is 0.text - the specified text to be parsedoffset - the starting index of stringlength - the specified length of stringfeatures - the specified features is applied to parsingJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(java.lang.String text,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received String is null or empty.text - the specified text to be parsedcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic java.lang.Object parse(byte[] bytes,
JSONReader.Feature... features)
JSONArray or JSONObject.
Returns null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedfeatures - the specified features is applied to parsingJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(byte[] bytes,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(char[] chars,
JSONReader.Feature... features)
JSONArray or JSONObject.
Returns null if received char array is null or empty.chars - the specified char array to be parsedfeatures - the specified features is applied to parsingJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(char[] chars,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received char array is null or empty.chars - the specified char array to be parsedcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursstatic java.lang.Object parse(java.io.InputStream in,
JSONReader.Feature... features)
JSONArray or JSONObject.
Returns null if received InputStream is null or empty.in - the specified stream to be parsedfeatures - the specified features is applied to parsingJSONArray or JSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic java.lang.Object parse(java.io.InputStream in,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received InputStream is null or empty.in - the specified stream to be parsedcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic java.lang.Object parse(java.io.InputStream in,
java.nio.charset.Charset charset)
JSONArray or JSONObject.
Returns null if received InputStream is null or empty.in - the specified stream to be parsedcharset - the specified charset of the streamJSONArray or JSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic java.lang.Object parse(java.io.InputStream in,
java.nio.charset.Charset charset,
JSONReader.Context context)
JSONArray or JSONObject.
Returns null if received InputStream is null or empty.in - the specified stream to be parsedcharset - the specified charset of the streamcontext - the specified custom contextJSONArray or JSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic JSONObject parseObject(java.lang.String text)
JSONObject. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.lang.String text, JSONReader.Feature... features)
JSONObject. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.lang.String text, int offset, int length, JSONReader.Feature... features)
JSONObject. Returns null if received
String is null or empty or length is 0 or its content is null.text - the specified text to be parsedoffset - the starting index of stringlength - the specified length of stringfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.lang.String text, int offset, int length, JSONReader.Context context)
JSONObject. Returns null if received
String is null or empty or length is 0 or its content is null.text - the specified text to be parsedoffset - the starting index of stringlength - the specified length of stringcontext - the specified custom contextJSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic JSONObject parseObject(java.lang.String text, JSONReader.Context context)
JSONObject. Returns null if
received String is null or empty or its content is null.text - the specified string to be parsedcontext - the specified custom contextJSONObject or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic JSONObject parseObject(java.io.Reader input, JSONReader.Feature... features)
JSONObject. Returns null
if received Reader is null or its content is null.input - the specified reader to be parsedfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.io.InputStream input, JSONReader.Feature... features)
JSONObject. Returns null if
received InputStream is null or closed or its content is null.input - the specified stream to be parsedfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(byte[] bytes)
JSONObject. Returns null
if received byte array is null or empty or its content is null.bytes - the specified UTF8 text to be parsedJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(char[] chars)
JSONObject. Returns null
if received char array is null or empty or its content is null.chars - the specified char array to be parsedJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.io.InputStream in, java.nio.charset.Charset charset)
JSONObject. Returns null
if received InputStream is null or its content is null.in - the specified stream to be parsedcharset - the specified charset of the streamJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.io.InputStream input, java.nio.charset.Charset charset, JSONReader.Context context)
JSONObject. Returns null if
received InputStream is null or closed or its content is null.input - the specified stream to be parsedcharset - the specified charset of the streamcontext - the specified custom contextJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(java.net.URL url)
url - the specified url to be parsedJSONObject or nullJSONException - If an I/O error or parsing error occursURL.openStream(),
parseObject(InputStream, Charset)static JSONObject parseObject(byte[] bytes, JSONReader.Feature... features)
JSONObject. Returns null
if received byte array is null or empty or its content is null.bytes - the specified UTF8 text to be parsedfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(byte[] bytes, int offset, int length, JSONReader.Feature... features)
JSONObject. Returns null if
received byte array is null or empty or length is 0 or its content is null.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arrayfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(char[] chars, int offset, int length, JSONReader.Feature... features)
JSONObject. Returns null if
received chars array is null or empty or length is 0 or its content is null.chars - the specified chars array to be parsedoffset - the starting index of arraylength - the specified length of arrayfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursstatic JSONObject parseObject(byte[] bytes, int offset, int length, java.nio.charset.Charset charset, JSONReader.Feature... features)
JSONObject. Returns null if
received byte array is null or empty or length is 0 or its content is null.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamfeatures - the specified features is applied to parsingJSONObject or nullJSONException - If a parsing error occursparseObject(byte[], int, int, JSONReader.Feature...)static <T> T parseObject(java.lang.String text,
java.lang.Class<T> clazz)
T. Returns
null if received String is null or empty.text - the specified string to be parsedclazz - the specified class of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.Class<T> clazz,
Filter filter,
JSONReader.Feature... features)
T. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedclazz - the specified class of Tfilter - the specified filter is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type,
java.lang.String format,
Filter[] filters,
JSONReader.Feature... features)
T. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedtype - the specified actual type of Tformat - the specified date formatfilters - the specified filters is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual type of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Context context)
T. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedtype - the specified actual type of Tcontext - the specified custom contextT or nullJSONException - If a parsing error occursstatic <T extends java.util.Map<java.lang.String,java.lang.Object>> T parseObject(java.lang.String text,
MapMultiValueType<T> type)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual type of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type... types)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtypes - the specified actual parameter typesT or nullJSONException - If a parsing error occursMultiType,
parseObject(String, Type)static <T> T parseObject(java.lang.String text,
TypeReference<T> typeReference,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtypeReference - the specified actual typefeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
TypeReference<T> typeReference,
Filter filter,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtypeReference - the specified actual typefilter - the specified filter is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedclazz - the specified class of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
int offset,
int length,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
T. Returns null
if received String is null or empty or length is 0.text - the specified string to be parsedoffset - the starting index of stringlength - the specified length of stringclazz - the specified class of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.Class<T> clazz,
JSONReader.Context context)
T. Returns
null if received String is null or empty.text - the specified string to be parsedclazz - the specified class of Tcontext - the specified custom contextT or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic <T> T parseObject(java.lang.String text,
java.lang.Class<T> clazz,
java.lang.String format,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedclazz - the specified class of Tformat - the specified date formatfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual typefeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type,
Filter filter,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual typefilter - the specified filter is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.lang.String text,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual typeformat - the specified date formatfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(char[] chars,
int offset,
int length,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns null
if received char array is null or empty or length is 0.chars - the specified char array to be parsedtype - the specified actual typeoffset - the starting index of arraylength - the specified length of arrayfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(char[] chars,
java.lang.Class<T> clazz)
T. Returns
null if received char array is null or empty.chars - the specified char array to be parsedclazz - the specified class of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
int offset,
int length,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns null
if received byte array is null or empty or length is 0.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraytype - the specified actual typefeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual type of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.Class<T> clazz)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedclazz - the specified class of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.Class<T> clazz,
Filter filter,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedclazz - the specified class of Tfilter - the specified filter is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.Class<T> clazz,
JSONReader.Context context)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedclazz - the specified class of Tcontext - the specified custom contextT or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type,
java.lang.String format,
Filter[] filters,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual typeformat - the specified date formatfilters - the specified filters is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Context context)
T. Returns
null if received String is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual typecontext - the specified custom contextT or nullJSONException - If a parsing error occursjava.lang.NullPointerException - If received context is nullstatic <T> T parseObject(byte[] bytes,
java.lang.Class<T> clazz,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedclazz - the specified class of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(char[] chars,
java.lang.Class<T> objectClass,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.chars - the specified charsobjectClass - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(char[] chars,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.chars - the specified charstype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type,
Filter filter,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual type of Tfilter - the specified filter is applied to parsingfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual type of Tformat - the specified date formatfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.nio.ByteBuffer buffer,
java.lang.Class<T> objectClass)
T. Returns
null if received ByteBuffer is null.buffer - the specified buffer to be parsedobjectClass - the specified class of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.io.Reader input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns null
if received Reader is null or its content is null.input - the specified reader to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns null
if received InputStream is null or its content is null.input - the specified stream to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.reflect.Type type,
JSONReader.Context context)
T. Returns null
if received InputStream is null or its content is null.input - the specified stream to be parsedtype - the specified actual type of Tcontext - the specified custom contextT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Context context)
T. Returns null
if received InputStream is null or its content is null.input - the specified stream to be parsedtype - the specified actual type of Tcontext - the specified custom contextT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.net.URL url,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T.
Returns null if received URL is null.url - the specified url to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If an I/O error or parsing error occursURL.openStream(),
parseObject(InputStream, Type, JSONReader.Feature...)static <T> T parseObject(java.net.URL url,
java.lang.Class<T> objectClass,
JSONReader.Feature... features)
T.
Returns null if received URL is null.url - the specified url to be parsedobjectClass - the specified class of Tfeatures - the specified features is applied to parsingT or nullJSONException - If an I/O error or parsing error occursURL.openStream(),
parseObject(InputStream, Type, JSONReader.Feature...)static <T> T parseObject(java.net.URL url,
java.util.function.Function<JSONObject,T> function,
JSONReader.Feature... features)
JSONObject and call the function
to convert it to T. Returns null if received URL is null.url - the specified url to be parsedfunction - the specified converterfeatures - the specified features is applied to parsingT or nullJSONException - If an I/O error or parsing error occursURL.openStream(),
parseObject(InputStream, JSONReader.Feature...)static <T> T parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
java.lang.String format,
JSONReader.Feature... features)
T. Returns null
if received InputStream is null or its content is null.input - the specified stream to be parsedtype - the specified actual type of Tformat - the specified date formatfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns null
if received InputStream is null or its content is null.input - the specified stream to be parsedcharset - the specified charset of the streamtype - the specified actual type of Tfeatures - the specified features is applied to parsingT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.reflect.Type type)
T. Returns null
if received byte array is null or empty or length is 0.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamtype - the specified actual type of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type)
T. Returns null
if received byte array is null or empty or length is 0.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamtype - the specified actual type of TT or nullJSONException - If a parsing error occursstatic <T> T parseObject(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Feature... features)
T. Returns null
if received byte array is null or empty or length is 0.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamtype - the specified actual class of TT or nullJSONException - If a parsing error occursstatic <T> void parseObject(java.io.InputStream input,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer,
JSONReader.Feature... features)
T objects and call the specified consumer to consume itinput - the specified stream to be parsedtype - the specified actual class of Tconsumer - the specified consumer is called multiple timesfeatures - the specified features is applied to parsingJSONException - If an I/O error or parsing error occursjava.lang.NullPointerException - If the specified stream is nullstatic <T> void parseObject(java.io.InputStream input,
java.nio.charset.Charset charset,
char delimiter,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer,
JSONReader.Feature... features)
T objects and call the specified consumer to consume itinput - the specified stream to be parsedcharset - the specified charset of the streamtype - the specified actual class of Tdelimiter - the specified delimiter for the streamconsumer - the specified consumer is called multiple timesfeatures - the specified features is applied to parsingJSONException - If an I/O error or parsing error occursjava.lang.NullPointerException - If the specified stream is nullstatic <T> void parseObject(java.io.Reader input,
char delimiter,
java.lang.reflect.Type type,
java.util.function.Consumer<T> consumer)
T objects and call the specified consumer to consume itinput - the specified reader to be parsedtype - the specified actual class of Tdelimiter - the specified delimiter for the streamconsumer - the specified consumer is called multiple timesJSONException - If an I/O error or parsing error occursjava.lang.NullPointerException - If the specified reader is nullstatic JSONArray parseArray(java.lang.String text)
JSONArray. Returns null if
received String is null or empty or its content is null.text - the specified string to be parsedJSONArray or nullJSONException - If a parsing error occursstatic JSONArray parseArray(byte[] bytes)
JSONArray. Returns null
if received byte array is null or empty or its content is null.bytes - the specified UTF8 text to be parsedJSONArray or nullJSONException - If a parsing error occursstatic JSONArray parseArray(byte[] bytes, int offset, int length, java.nio.charset.Charset charset)
JSONArray. Returns null
if received byte array is null or empty or length is 0 or its content is null.bytes - the specified byte array to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamJSONException - If a parsing error occursstatic JSONArray parseArray(char[] chars)
JSONArray. Returns null
if received byte array is null or empty or its content is null.chars - the specified char array to be parsedJSONArray or nullJSONException - If a parsing error occursstatic JSONArray parseArray(java.lang.String text, JSONReader.Feature... features)
JSONArray. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedfeatures - the specified features is applied to parsingJSONArray or nullJSONException - If a parsing error occursstatic JSONArray parseArray(java.net.URL url, JSONReader.Feature... features)
url - the specified url to be parsedfeatures - the specified features is applied to parsingJSONArray or nullJSONException - If an I/O error or parsing error occursURL.openStream(),
parseArray(InputStream, JSONReader.Feature...)static JSONArray parseArray(java.io.Reader input, JSONReader.Feature... features)
JSONArray. Returns null
if received Reader is null or its content is null.input - the specified reader to be parsedfeatures - the specified features is applied to parsingJSONArray or nullJSONException - If an I/O error or parsing error occursstatic JSONArray parseArray(java.io.InputStream in, JSONReader.Feature... features)
JSONArray. Returns null
if received InputStream is null or its content is null.in - the specified stream to be parsedfeatures - the specified features is applied to parsingJSONArray or nullJSONException - If an I/O error or parsing error occursstatic JSONArray parseArray(java.io.InputStream in, java.nio.charset.Charset charset, JSONReader.Context context)
JSONArray. Returns null
if received InputStream is null or its content is null.in - the specified stream to be parsedcharset - the specified charset of the streamcontext - the specified custom contextJSONArray or nullJSONException - If an I/O error or parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.reflect.Type type)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual type of TList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.Class<T> type)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual class of TList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.reflect.Type... types)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtypes - the specified actual parameter typeList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.Class<T> type,
JSONReader.Feature... features)
T. Returns
null if received String is null or empty.text - the specified string to be parsedtype - the specified actual class of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(char[] chars,
java.lang.Class<T> type,
JSONReader.Feature... features)
T. Returns
null if received char array is null or empty.chars - the specified char array to be parsedtype - the specified actual class of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.reflect.Type[] types,
JSONReader.Feature... features)
T. Returns null
if received String is null or empty or its content is null.text - the specified string to be parsedtypes - the specified actual parameter typefeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(java.io.Reader input,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received Reader is null or empty.input - the specified reader to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(byte[] bytes,
java.lang.reflect.Type type,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual type of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(byte[] bytes,
java.lang.Class<T> type,
JSONReader.Feature... features)
T. Returns
null if received byte array is null or empty.bytes - the specified UTF8 text to be parsedtype - the specified actual class of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic <T> java.util.List<T> parseArray(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset,
java.lang.Class<T> type,
JSONReader.Feature... features)
T. Returns null
if received byte array is null or empty or the specified length is 0.bytes - the specified UTF8 text to be parsedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the streamtype - the specified actual class of Tfeatures - the specified features is applied to parsingList or nullJSONException - If a parsing error occursstatic java.lang.String toJSONString(java.lang.Object object)
object - the specified object will be serializedString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
JSONWriter.Context context)
object - the specified object will be serializedcontext - the specified custom contextString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
JSONWriter.Feature... features)
object - the specified object will be serializedfeatures - the specified features is applied to serializationString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
Filter filter,
JSONWriter.Feature... features)
object - the specified object will be serializedfilter - the specified filter is applied to serializationfeatures - the specified features is applied to serializationString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
object - the specified object will be serializedfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
java.lang.String format,
JSONWriter.Feature... features)
object - the specified object will be serializedformat - the specified date formatfeatures - the specified features is applied to serializationString that is not nullJSONException - If a serialization error occursstatic java.lang.String toJSONString(java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
object - the specified object will be serializedformat - the specified date formatfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationString that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object)
object - the specified object will be serializedbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
java.nio.charset.Charset charset,
JSONWriter.Feature... features)
object - the specified object will be serializedcharset - the specified charset of the bytesbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
java.nio.charset.Charset charset,
JSONWriter.Context context)
object - the specified object will be serializedcharset - the specified charset of the bytescontext - the specified custom contextbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
java.lang.String format,
JSONWriter.Feature... features)
object - the specified object will be serializedformat - the specified date formatfeatures - the specified features is applied to serializationbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
Filter... filters)
object - the specified object will be serializedfilters - the specified filters is applied to serializationbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
JSONWriter.Feature... features)
object - the specified object will be serializedfeatures - the specified features is applied to serializationbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
object - the specified object will be serializedfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationbyte[] that is not nullJSONException - If a serialization error occursstatic byte[] toJSONBytes(java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
object - the specified object will be serializedformat - the specified date formatfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationbyte[] that is not nullJSONException - If a serialization error occursstatic int writeTo(java.io.OutputStream out,
java.lang.Object object)
OutputStreamout - the specified output stream to be writtenobject - the specified object will be serializedJSONException - If an I/O error or serialization error occursstatic int writeTo(java.io.OutputStream out,
java.lang.Object object,
JSONWriter.Context context)
OutputStreamout - the specified output stream to be writtenobject - the specified object will be serializedcontext - the specified custom contextJSONException - If an I/O error or serialization error occursstatic int writeTo(java.io.OutputStream out,
java.lang.Object object,
JSONWriter.Feature... features)
OutputStreamout - the specified output stream to be writtenobject - the specified object will be serializedfeatures - the specified features is applied to serializationJSONException - If an I/O error or serialization error occursstatic int writeTo(java.io.OutputStream out,
java.lang.Object object,
Filter[] filters,
JSONWriter.Feature... features)
OutputStreamout - the specified output stream to be writtenobject - the specified object will be serializedfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationJSONException - If an I/O error or serialization error occursstatic int writeTo(java.io.OutputStream out,
java.lang.Object object,
java.lang.String format,
Filter[] filters,
JSONWriter.Feature... features)
OutputStreamout - the specified output stream to be writtenobject - the specified object will be serializedformat - the specified date formatfilters - the specified filters is applied to serializationfeatures - the specified features is applied to serializationJSONException - If an I/O error or serialization error occursstatic boolean isValid(java.lang.String text)
text - the specified string will be validatedtrue or falsestatic boolean isValid(java.lang.String text,
JSONReader.Feature... features)
text - the specified string will be validatedfeatures - the specified features is applied to parsingtrue or falsestatic boolean isValid(char[] chars)
chars - the specified array will be validatedtrue or falsestatic boolean isValidObject(java.lang.String text)
text - the specified string will be validatedtrue or falsestatic boolean isValidObject(byte[] bytes)
bytes - the specified array will be validatedtrue or falsestatic boolean isValidArray(java.lang.String text)
String is JSON Arraytext - the String to validatetrue or falsestatic boolean isValid(byte[] bytes)
bytes - the specified array will be validatedtrue or falsestatic boolean isValid(byte[] bytes,
java.nio.charset.Charset charset)
bytes - the specified array will be validatedcharset - the specified charset of the bytestrue or falsestatic boolean isValidArray(byte[] bytes)
bytes - the specified array will be validatedtrue or falsestatic boolean isValid(byte[] bytes,
int offset,
int length,
java.nio.charset.Charset charset)
bytes - the specified array will be validatedoffset - the starting index of arraylength - the specified length of arraycharset - the specified charset of the bytestrue or falsestatic java.lang.Object toJSON(java.lang.Object object)
object - the specified object to be convertedJSONArray or JSONObject or nullstatic java.lang.Object toJSON(java.lang.Object object,
JSONWriter.Feature... features)
object - the specified object to be convertedfeatures - the specified features is applied to serializationJSONArray or JSONObject or nullstatic <T> T to(java.lang.Class<T> clazz,
java.lang.Object object)
T - the target typeclazz - the specified goal classobject - the specified object to be convertedstatic <T> T toJavaObject(java.lang.Object object,
java.lang.Class<T> clazz)
to(Class, Object)T - the target typeobject - the specified object to be convertedclazz - the specified goal classstatic void mixIn(java.lang.Class<?> target,
java.lang.Class<?> mixinSource)
target - the target class to mix intomixinSource - the source class to mix fromstatic ObjectReader<?> register(java.lang.reflect.Type type, ObjectReader<?> objectReader)
type - the type to register an ObjectReader forobjectReader - the ObjectReader to registerJSONFactory.getDefaultObjectReaderProvider(),
ObjectReaderProvider.register(Type, ObjectReader)static ObjectReader<?> register(java.lang.reflect.Type type, ObjectReader<?> objectReader, boolean fieldBased)
type - the type to register an ObjectReader forobjectReader - the ObjectReader to registerfieldBased - whether to use field-based readingJSONFactory.getDefaultObjectReaderProvider(),
ObjectReaderProvider.register(Type, ObjectReader)static ObjectReader<?> registerIfAbsent(java.lang.reflect.Type type, ObjectReader<?> objectReader)
type - the type to register an ObjectReader forobjectReader - the ObjectReader to registerJSONFactory.getDefaultObjectReaderProvider(),
ObjectReaderProvider.registerIfAbsent(Type, ObjectReader)static ObjectReader<?> registerIfAbsent(java.lang.reflect.Type type, ObjectReader<?> objectReader, boolean fieldBased)
type - the type to register an ObjectReader forobjectReader - the ObjectReader to registerfieldBased - whether to use field-based readingJSONFactory.getDefaultObjectReaderProvider(),
ObjectReaderProvider.registerIfAbsent(Type, ObjectReader)static boolean register(ObjectReaderModule objectReaderModule)
ObjectReaderModule in default ObjectReaderProviderobjectReaderModule - the ObjectReaderModule to registerJSONFactory.getDefaultObjectReaderProvider(),
ObjectReaderProvider.register(ObjectReaderModule)static void registerSeeAlsoSubType(java.lang.Class subTypeClass)
subTypeClass - the sub type class to registerstatic void registerSeeAlsoSubType(java.lang.Class subTypeClass,
java.lang.String subTypeClassName)
subTypeClass - the sub type class to registersubTypeClassName - the class name for the sub typestatic boolean register(ObjectWriterModule objectWriterModule)
ObjectWriterModule in default ObjectWriterProviderobjectWriterModule - the ObjectWriterModule to registerJSONFactory.getDefaultObjectWriterProvider(),
ObjectWriterProvider.register(ObjectWriterModule)static ObjectWriter<?> register(java.lang.reflect.Type type, ObjectWriter<?> objectWriter)
type - the type to register an ObjectWriter forobjectWriter - the ObjectWriter to registerJSONFactory.getDefaultObjectWriterProvider(),
ObjectWriterProvider.register(Type, ObjectWriter)static ObjectWriter<?> register(java.lang.reflect.Type type, ObjectWriter<?> objectWriter, boolean fieldBased)
type - the type to register an ObjectWriter forobjectWriter - the ObjectWriter to registerfieldBased - whether to use field-based writingJSONFactory.getDefaultObjectWriterProvider(),
ObjectWriterProvider.register(Type, ObjectWriter)static ObjectWriter<?> registerIfAbsent(java.lang.reflect.Type type, ObjectWriter<?> objectWriter)
type - the type to register an ObjectWriter forobjectWriter - the ObjectWriter to registerJSONFactory.getDefaultObjectWriterProvider(),
ObjectWriterProvider.registerIfAbsent(Type, ObjectWriter)static ObjectWriter<?> registerIfAbsent(java.lang.reflect.Type type, ObjectWriter<?> objectWriter, boolean fieldBased)
type - the type to register an ObjectWriter forobjectWriter - the ObjectWriter to registerfieldBased - whether to use field-based writingJSONFactory.getDefaultObjectWriterProvider(),
ObjectWriterProvider.registerIfAbsent(Type, ObjectWriter)static void register(java.lang.Class type,
Filter filter)
type - the class type to register filter forfilter - the filter to apply to the specified typestatic void config(JSONReader.Feature... features)
features - the specified features to be usedstatic void config(JSONReader.Feature feature, boolean state)
feature - the specified feature to be usedstate - enable this feature if and only if state is true, disable otherwisestatic boolean isEnabled(JSONReader.Feature feature)
feature - the specified featurestatic void configReaderDateFormat(java.lang.String dateFormat)
dateFormat - the date format to use for readingstatic void configWriterDateFormat(java.lang.String dateFormat)
dateFormat - the date format to use for writingstatic void configReaderZoneId(java.time.ZoneId zoneId)
zoneId - the zone ID to use for readingstatic void configWriterZoneId(java.time.ZoneId zoneId)
zoneId - the zone ID to use for writingstatic void config(JSONWriter.Feature... features)
features - the specified features to be usedstatic void config(JSONWriter.Feature feature, boolean state)
feature - the specified feature to be usedstate - enable this feature if and only if state is true, disable otherwisestatic boolean isEnabled(JSONWriter.Feature feature)
feature - the specified featurestatic <T> T copy(T object,
JSONWriter.Feature... features)
T using the properties of the specified objectT - the type of the object to copyobject - the specified object will be copiedfeatures - the specified features is applied to serializationstatic <T> T copyTo(java.lang.Object object,
java.lang.Class<T> targetClass,
JSONWriter.Feature... features)
T - the target typeobject - the specified object will be copiedtargetClass - the specified target classfeatures - the specified features is applied to serialization@SafeVarargs static void configEnumAsJavaBean(java.lang.Class<? extends java.lang.Enum>... enumClasses)
enumClasses - the enum classes to configure as JavaBeans