public class JSON
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JSON.ByteArrayAdapter
Gson TypeAdapter for Byte Array type
|
static class |
JSON.DateTypeAdapter
Gson TypeAdapter for java.util.Date type
If the dateFormat is null, ISO8601Utils will be used.
|
static class |
JSON.LocalDateTypeAdapter
Gson TypeAdapter for JSR310 LocalDate type
|
static class |
JSON.OffsetDateTimeTypeAdapter
Gson TypeAdapter for JSR310 OffsetDateTime type
|
static class |
JSON.SqlDateTypeAdapter
Gson TypeAdapter for java.sql.Date type
If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
(more efficient than SimpleDateFormat).
|
| Constructor and Description |
|---|
JSON() |
| Modifier and Type | Method and Description |
|---|---|
static com.google.gson.GsonBuilder |
createGson() |
static <T> T |
deserialize(java.lang.String body,
java.lang.reflect.Type returnType)
Deserialize the given JSON string to Java object.
|
static com.google.gson.Gson |
getGson()
Get Gson.
|
static java.lang.String |
serialize(java.lang.Object obj)
Serialize the given Java object into JSON string.
|
static void |
setDateFormat(java.text.DateFormat dateFormat) |
static void |
setGson(com.google.gson.Gson gson)
Set Gson.
|
static void |
setLenientOnJson(boolean lenientOnJson) |
static void |
setLocalDateFormat(java.time.format.DateTimeFormatter dateFormat) |
static void |
setOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat) |
static void |
setSqlDateFormat(java.text.DateFormat dateFormat) |
public static com.google.gson.GsonBuilder createGson()
public static com.google.gson.Gson getGson()
public static void setGson(com.google.gson.Gson gson)
gson - Gsonpublic static void setLenientOnJson(boolean lenientOnJson)
public static java.lang.String serialize(java.lang.Object obj)
obj - Objectpublic static <T> T deserialize(java.lang.String body,
java.lang.reflect.Type returnType)
T - Typebody - The JSON stringreturnType - The type to deserialize intopublic static void setOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat)
public static void setLocalDateFormat(java.time.format.DateTimeFormatter dateFormat)
public static void setDateFormat(java.text.DateFormat dateFormat)
public static void setSqlDateFormat(java.text.DateFormat dateFormat)