Package kong.unirest.modules.gson
Class GsonObjectMapper
- java.lang.Object
-
- kong.unirest.modules.gson.GsonObjectMapper
-
- All Implemented Interfaces:
ObjectMapper
public class GsonObjectMapper extends java.lang.Object implements ObjectMapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classGsonObjectMapper.CalendarSerializerprivate static classGsonObjectMapper.DateAdapterprivate static classGsonObjectMapper.DateTimeAdapter<T>private static classGsonObjectMapper.LocalDateAdapterprivate static classGsonObjectMapper.LocalDateTimeAdapterprivate static classGsonObjectMapper.ZonedDateAdapter
-
Constructor Summary
Constructors Constructor Description GsonObjectMapper()GsonObjectMapper(com.google.gson.Gson gson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private com.google.gson.GsongetGson()<T> TreadValue(java.lang.String value, java.lang.Class<T> valueType)reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.<T> TreadValue(java.lang.String value, GenericType<T> genericType)reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.java.lang.StringwriteValue(java.lang.Object value)Takes a object and serialize it as a string.
-
-
-
Field Detail
-
ISO_8601
public static final java.lang.String ISO_8601
- See Also:
- Constant Field Values
-
gson
private com.google.gson.Gson gson
-
-
Method Detail
-
readValue
public <T> T readValue(java.lang.String value, java.lang.Class<T> valueType)Description copied from interface:ObjectMapperreads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.- Specified by:
readValuein interfaceObjectMapper- Type Parameters:
T- the type- Parameters:
value- the content as a string.valueType- the type to map to- Returns:
- the object mapped into the class type
-
readValue
public <T> T readValue(java.lang.String value, GenericType<T> genericType)Description copied from interface:ObjectMapperreads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder. This method takes a GenericType which retains Generics information for types lke List<Foo>- Specified by:
readValuein interfaceObjectMapper- Type Parameters:
T- the type- Parameters:
value- the content as a string.genericType- the generic type- Returns:
- the object mapped into the class type
-
writeValue
public java.lang.String writeValue(java.lang.Object value)
Description copied from interface:ObjectMapperTakes a object and serialize it as a string. This is used to map objects to bodies to pass to requests- Specified by:
writeValuein interfaceObjectMapper- Parameters:
value- the object to serialize to a string- Returns:
- the serialized string of the object
-
getGson
private com.google.gson.Gson getGson()
-
-