Package org.openapitools.client
Class JSON
java.lang.Object
org.openapitools.client.JSON
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Gson TypeAdapter for Byte Array typestatic class
Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used.static class
Gson TypeAdapter for JSR310 LocalDate typestatic class
Gson TypeAdapter for JSR310 OffsetDateTime typestatic class
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
FieldsModifier and TypeFieldDescriptionprivate static JSON.ByteArrayAdapter
private static JSON.DateTypeAdapter
private static com.google.gson.Gson
private static boolean
private static JSON.LocalDateTypeAdapter
private static JSON.OffsetDateTimeTypeAdapter
private static JSON.SqlDateTypeAdapter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.GsonBuilder
static <T> T
deserialize
(String body, Type returnType) Deserialize the given JSON string to Java object.private static Class
getClassByDiscriminator
(Map classByDiscriminatorValue, String discriminatorValue) Returns the Java class that implements the OpenAPI schema for the specified discriminator value.private static String
getDiscriminatorValue
(com.google.gson.JsonElement readElement, String discriminatorField) static com.google.gson.Gson
getGson()
Get Gson.static String
Serialize the given Java object into JSON string.static void
setDateFormat
(DateFormat dateFormat) static void
setGson
(com.google.gson.Gson gson) Set Gson.static void
setLenientOnJson
(boolean lenientOnJson) static void
setLocalDateFormat
(DateTimeFormatter dateFormat) static void
setOffsetDateTimeFormat
(DateTimeFormatter dateFormat) static void
setSqlDateFormat
(DateFormat dateFormat)
-
Field Details
-
gson
private static com.google.gson.Gson gson -
isLenientOnJson
private static boolean isLenientOnJson -
dateTypeAdapter
-
sqlDateTypeAdapter
-
offsetDateTimeTypeAdapter
-
localDateTypeAdapter
-
byteArrayAdapter
-
-
Constructor Details
-
JSON
public JSON()
-
-
Method Details
-
createGson
public static com.google.gson.GsonBuilder createGson() -
getDiscriminatorValue
-
getClassByDiscriminator
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) Returns the Java class that implements the OpenAPI schema for the specified discriminator value.- Parameters:
classByDiscriminatorValue
- The map of discriminator values to Java classes.discriminatorValue
- The value of the OpenAPI discriminator in the input data.- Returns:
- The Java class that implements the OpenAPI schema
-
getGson
public static com.google.gson.Gson getGson()Get Gson.- Returns:
- Gson
-
setGson
public static void setGson(com.google.gson.Gson gson) Set Gson.- Parameters:
gson
- Gson
-
setLenientOnJson
public static void setLenientOnJson(boolean lenientOnJson) -
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
-