Package kubevirt
Class JSON
java.lang.Object
kubevirt.JSON
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassGson TypeAdapter for Byte Array typestatic classGson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used.classGson TypeAdapter for JSR310 LocalDate typestatic classGson TypeAdapter for JSR310 OffsetDateTime typestatic classGson 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
FieldsModifier and TypeFieldDescriptionprivate JSON.ByteArrayAdapterprivate JSON.DateTypeAdapterprivate com.google.gson.Gsonprivate booleanprivate JSON.LocalDateTypeAdapterprivate JSON.OffsetDateTimeTypeAdapterprivate JSON.SqlDateTypeAdapter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.GsonBuilder<T> Tdeserialize(String body, Type returnType) Deserialize the given JSON string to Java object.private static ClassgetClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) private static StringgetDiscriminatorValue(com.google.gson.JsonElement readElement, String discriminatorField) com.google.gson.GsongetGson()Get Gson.Serialize the given Java object into JSON string.setDateFormat(DateFormat dateFormat) setGson(com.google.gson.Gson gson) Set Gson.setLenientOnJson(boolean lenientOnJson) setLocalDateFormat(DateTimeFormatter dateFormat) setOffsetDateTimeFormat(DateTimeFormatter dateFormat) setSqlDateFormat(DateFormat dateFormat)
-
Field Details
-
gson
private com.google.gson.Gson gson -
isLenientOnJson
private boolean isLenientOnJson -
dateTypeAdapter
-
sqlDateTypeAdapter
-
offsetDateTimeTypeAdapter
-
localDateTypeAdapter
-
byteArrayAdapter
-
-
Constructor Details
-
JSON
public JSON()
-
-
Method Details
-
createGson
public static com.google.gson.GsonBuilder createGson() -
getDiscriminatorValue
-
getClassByDiscriminator
-
getGson
public com.google.gson.Gson getGson()Get Gson.- Returns:
- Gson
-
setGson
Set Gson.- Parameters:
gson- Gson- Returns:
- JSON
-
setLenientOnJson
-
serialize
Serialize the given Java object into JSON string.- Parameters:
obj- Object- Returns:
- String representation of the JSON
-
deserialize
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
-
setLocalDateFormat
-
setDateFormat
-
setSqlDateFormat
-