public final class JSONParser extends Object
Modifier and Type | Method and Description |
---|---|
static @NotNull Object |
deserialize(@NotNull Reader reader)
|
static @NotNull Object |
deserialize(@NotNull String data)
|
static @Nullable JSONArray |
deserializeArray(@NotNull Reader reader)
|
static @Nullable JSONArray |
deserializeArray(@NotNull String data)
|
static @Nullable JSONObject |
deserializeObject(@NotNull Reader reader)
Deserializes the data in the given
Reader into a
JSONObject . |
static @Nullable JSONObject |
deserializeObject(@NotNull String data)
Deserializes the given
String data into a JSONObject . |
static @NotNull String |
format(@NotNull Reader reader)
Formats the JSON data in the given
Reader into a human-readable
format using indentation and newlines. |
static @NotNull String |
format(@NotNull Reader reader,
@NotNull String indent,
@NotNull String newline)
Formats the gSON data in the given
Reader into a human-readable
format using indentation and newlines, both of the caller's choice. |
static @NotNull String |
format(@NotNull String data)
Formats the given
String JSON data into a human-readable format
using indentation and newlines. |
static @NotNull String |
format(@NotNull String data,
@NotNull String indent,
@NotNull String newline)
Formats the given
String JSON data into a human-readable format
using indentation and newlines, both of the caller's choice. |
static @NotNull String |
serialize(@Nullable Object data)
|
@NotNull public static @NotNull Object deserialize(@NotNull @NotNull String data) throws JSONException
data
- The JSON data in String
format.Object
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@NotNull public static @NotNull Object deserialize(@NotNull @NotNull Reader reader) throws JSONException
reader
- The Reader
containing the JSON data.Object
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@Nullable public static @Nullable JSONArray deserializeArray(@NotNull @NotNull String data) throws JSONException
data
- The JSON data in String
format.JSONArray
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@Nullable public static @Nullable JSONArray deserializeArray(@NotNull @NotNull Reader reader) throws JSONException
reader
- The Reader
containing the JSON data.JSONArray
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@Nullable public static @Nullable JSONObject deserializeObject(@NotNull @NotNull String data) throws JSONException
String
data into a JSONObject
.data
- The JSON data in String
format.JSONObject
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@Nullable public static @Nullable JSONObject deserializeObject(@NotNull @NotNull Reader reader) throws JSONException
Reader
into a
JSONObject
.reader
- The Reader
containing the JSON data.JSONObject
containing the deserialized JSON data.JSONException
- If an error occurs while deserializing the data.@NotNull public static @NotNull String serialize(@Nullable @Nullable Object data) throws JSONException
data
- The data as an Object
to serialize into JSON format.String
representation of the given data.JSONException
- If an error occurs while serializing the data.@NotNull public static @NotNull String format(@NotNull @NotNull String data) throws JSONException
String
JSON data into a human-readable format
using indentation and newlines. The indentation character used is
"\t"
, while the newline character used is "\n"
.data
- The JSON data as a String
.String
.JSONException
- If an error occurs while formatting the data.@NotNull public static @NotNull String format(@NotNull @NotNull Reader reader) throws JSONException
Reader
into a human-readable
format using indentation and newlines. The indentation character used is
"\t"
, while the newline character used is "\n"
.reader
- The Reader
containing the JSON data.String
.JSONException
- If an error occurs while formatting the data.@NotNull public static @NotNull String format(@NotNull @NotNull String data, @NotNull @NotNull String indent, @NotNull @NotNull String newline) throws JSONException
String
JSON data into a human-readable format
using indentation and newlines, both of the caller's choice. This means
the validity of the formatted JSON is dependent on the caller's choice of
indentation and newlines.data
- The JSON data as a String
.indent
- The String
to use as an indent.newline
- The String
to use as a newline.String
.JSONException
- If an error occurs while formatting the data.@NotNull public static @NotNull String format(@NotNull @NotNull Reader reader, @NotNull @NotNull String indent, @NotNull @NotNull String newline) throws JSONException
Reader
into a human-readable
format using indentation and newlines, both of the caller's choice. This
means the validity of the formatted JSON is dependent on the caller's
choice of indentation and newlines.reader
- The Reader
containing the JSON data.indent
- The String
to use as an indent.newline
- The String
to use as a newline.String
.JSONException
- If an error occurs while formatting the data.Copyright © 2021 BSPF Systems, LLC. All rights reserved.