public class Json extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Json.ByteArrayToBase64TypeAdapter |
static class |
Json.DateTypeAdapter
Gson TypeAdapter for java.util.Date type
If the dateFormat is null, ISO8601Utils will be used.
|
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() |
<T> T |
deserialize(String body,
Type returnType)
Deserialize the given Json string to Java object.
|
com.google.gson.Gson |
getGson()
Get Gson.
|
String |
serialize(Object obj)
Serialize the given Java object into Json string.
|
Json |
setDateFormat(DateFormat dateFormat) |
Json |
setGson(com.google.gson.Gson gson)
Set Gson.
|
Json |
setLenientOnJson(boolean lenientOnJson) |
Json |
setLocalDateFormat(org.threeten.bp.format.DateTimeFormatter dateFormat) |
Json |
setOffsetDateTimeFormat(org.threeten.bp.format.DateTimeFormatter dateFormat) |
Json |
setSqlDateFormat(DateFormat dateFormat) |
public static com.google.gson.GsonBuilder createGson()
public com.google.gson.Gson getGson()
public Json setGson(com.google.gson.Gson gson)
gson - Gsonpublic Json setLenientOnJson(boolean lenientOnJson)
public String serialize(Object obj)
obj - Objectpublic <T> T deserialize(String body, Type returnType)
T - Typebody - The Json stringreturnType - The type to deserialize intopublic Json setOffsetDateTimeFormat(org.threeten.bp.format.DateTimeFormatter dateFormat)
public Json setLocalDateFormat(org.threeten.bp.format.DateTimeFormatter dateFormat)
public Json setDateFormat(DateFormat dateFormat)
public Json setSqlDateFormat(DateFormat dateFormat)
Copyright © 2021. All rights reserved.