Package kubevirt
Class JSON
- java.lang.Object
-
- kubevirt.JSON
-
public class JSON extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JSON.ByteArrayAdapter
Gson TypeAdapter for Byte Array typestatic 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 typestatic class
JSON.OffsetDateTimeTypeAdapter
Gson TypeAdapter for JSR310 OffsetDateTime typestatic 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).
-
Field Summary
Fields Modifier and Type Field Description private JSON.ByteArrayAdapter
byteArrayAdapter
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
-
Constructor Summary
Constructors Constructor Description JSON()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static com.google.gson.GsonBuilder
createGson()
<T> T
deserialize(java.lang.String body, java.lang.reflect.Type returnType)
Deserialize the given JSON string to Java object.private static java.lang.Class
getClassByDiscriminator(java.util.Map classByDiscriminatorValue, java.lang.String discriminatorValue)
private static java.lang.String
getDiscriminatorValue(com.google.gson.JsonElement readElement, java.lang.String discriminatorField)
com.google.gson.Gson
getGson()
Get Gson.java.lang.String
serialize(java.lang.Object obj)
Serialize the given Java object into JSON string.JSON
setDateFormat(java.text.DateFormat dateFormat)
JSON
setGson(com.google.gson.Gson gson)
Set Gson.JSON
setLenientOnJson(boolean lenientOnJson)
JSON
setLocalDateFormat(java.time.format.DateTimeFormatter dateFormat)
JSON
setOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat)
JSON
setSqlDateFormat(java.text.DateFormat dateFormat)
-
-
-
Field Detail
-
gson
private com.google.gson.Gson gson
-
isLenientOnJson
private boolean isLenientOnJson
-
dateTypeAdapter
private JSON.DateTypeAdapter dateTypeAdapter
-
sqlDateTypeAdapter
private JSON.SqlDateTypeAdapter sqlDateTypeAdapter
-
offsetDateTimeTypeAdapter
private JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter
-
localDateTypeAdapter
private JSON.LocalDateTypeAdapter localDateTypeAdapter
-
byteArrayAdapter
private JSON.ByteArrayAdapter byteArrayAdapter
-
-
Method Detail
-
createGson
public static com.google.gson.GsonBuilder createGson()
-
getDiscriminatorValue
private static java.lang.String getDiscriminatorValue(com.google.gson.JsonElement readElement, java.lang.String discriminatorField)
-
getClassByDiscriminator
private static java.lang.Class getClassByDiscriminator(java.util.Map classByDiscriminatorValue, java.lang.String discriminatorValue)
-
getGson
public com.google.gson.Gson getGson()
Get Gson.- Returns:
- Gson
-
setGson
public JSON setGson(com.google.gson.Gson gson)
Set Gson.- Parameters:
gson
- Gson- Returns:
- JSON
-
setLenientOnJson
public JSON setLenientOnJson(boolean lenientOnJson)
-
serialize
public java.lang.String serialize(java.lang.Object obj)
Serialize the given Java object into JSON string.- Parameters:
obj
- Object- Returns:
- String representation of the JSON
-
deserialize
public <T> T deserialize(java.lang.String body, java.lang.reflect.Type returnType)
Deserialize the given JSON string to Java object.- Type Parameters:
T
- Type- Parameters:
body
- The JSON stringreturnType
- The type to deserialize into- Returns:
- The deserialized Java object
-
setOffsetDateTimeFormat
public JSON setOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat)
-
setLocalDateFormat
public JSON setLocalDateFormat(java.time.format.DateTimeFormatter dateFormat)
-
setDateFormat
public JSON setDateFormat(java.text.DateFormat dateFormat)
-
setSqlDateFormat
public JSON setSqlDateFormat(java.text.DateFormat dateFormat)
-
-