public class JSON extends Object
| 限定符和类型 | 类和说明 |
|---|---|
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).
|
| 限定符和类型 | 字段和说明 |
|---|---|
private JSON.DateTypeAdapter |
dateTypeAdapter |
private com.google.gson.Gson |
gson |
private boolean |
isLenientOnJson |
private JSON.LocalDateTypeAdapter |
localDateTypeAdapter |
private JSON.OffsetDateTimeTypeAdapter |
offsetDateTimeTypeAdapter |
private JSON.SqlDateTypeAdapter |
sqlDateTypeAdapter |
| 构造器和说明 |
|---|
JSON() |
| 限定符和类型 | 方法和说明 |
|---|---|
static com.google.gson.GsonBuilder |
createGson() |
<T> T |
deserialize(String body,
Type returnType)
Deserialize the given JSON string to Java object.
|
private static <T> Class<? extends T> |
getClassByDiscriminator(Map<String,Class<? extends T>> classByDiscriminatorValue,
String discriminatorValue) |
private static String |
getDiscriminatorValue(com.google.gson.JsonElement readElement,
String discriminatorField) |
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) |
private com.google.gson.Gson gson
private boolean isLenientOnJson
private JSON.DateTypeAdapter dateTypeAdapter
private JSON.SqlDateTypeAdapter sqlDateTypeAdapter
private JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter
private JSON.LocalDateTypeAdapter localDateTypeAdapter
public static com.google.gson.GsonBuilder createGson()
private static String getDiscriminatorValue(com.google.gson.JsonElement readElement, String discriminatorField)
private static <T> Class<? extends T> getClassByDiscriminator(Map<String,Class<? extends T>> classByDiscriminatorValue, String discriminatorValue)
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 © 2023. All rights reserved.