Package com.launchdarkly.api
Class JSON
- java.lang.Object
-
- com.launchdarkly.api.JSON
-
public class JSON extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJSON.ByteArrayAdapterGson TypeAdapter for Byte Array typestatic classJSON.DateTypeAdapterGson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used.static classJSON.LocalDateTypeAdapterGson TypeAdapter for JSR310 LocalDate typestatic classJSON.OffsetDateTimeTypeAdapterGson TypeAdapter for JSR310 OffsetDateTime typestatic classJSON.SqlDateTypeAdapterGson 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 Summary
Constructors Constructor Description JSON()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.gson.GsonBuildercreateGson()static <T> Tdeserialize(java.lang.String body, java.lang.reflect.Type returnType)Deserialize the given JSON string to Java object.static com.google.gson.GsongetGson()Get Gson.static java.lang.Stringserialize(java.lang.Object obj)Serialize the given Java object into JSON string.static voidsetDateFormat(java.text.DateFormat dateFormat)static voidsetGson(com.google.gson.Gson gson)Set Gson.static voidsetLenientOnJson(boolean lenientOnJson)static voidsetLocalDateFormat(java.time.format.DateTimeFormatter dateFormat)static voidsetOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat)static voidsetSqlDateFormat(java.text.DateFormat dateFormat)
-
-
-
Method Detail
-
createGson
public static com.google.gson.GsonBuilder createGson()
-
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
public static 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 static <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 static void setOffsetDateTimeFormat(java.time.format.DateTimeFormatter dateFormat)
-
setLocalDateFormat
public static void setLocalDateFormat(java.time.format.DateTimeFormatter dateFormat)
-
setDateFormat
public static void setDateFormat(java.text.DateFormat dateFormat)
-
setSqlDateFormat
public static void setSqlDateFormat(java.text.DateFormat dateFormat)
-
-