Package kong.unirest.jackson
Class JacksonObjectMapper
- java.lang.Object
-
- kong.unirest.jackson.JacksonObjectMapper
-
- All Implemented Interfaces:
ObjectMapper
public class JacksonObjectMapper extends java.lang.Object implements ObjectMapper
-
-
Field Summary
Fields Modifier and Type Field Description private com.fasterxml.jackson.databind.ObjectMapper
om
-
Constructor Summary
Constructors Constructor Description JacksonObjectMapper()
JacksonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper om)
JacksonObjectMapper(java.util.function.Consumer<com.fasterxml.jackson.databind.ObjectMapper> configurations)
Pass in any additional ObjectMapper configurations you want
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.ObjectMapper
getJacksonMapper()
<T> T
readValue(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> T
readValue(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.String
writeValue(java.lang.Object value)
Takes a object and serialize it as a string.
-
-
-
Constructor Detail
-
JacksonObjectMapper
public JacksonObjectMapper()
-
JacksonObjectMapper
public JacksonObjectMapper(java.util.function.Consumer<com.fasterxml.jackson.databind.ObjectMapper> configurations)
Pass in any additional ObjectMapper configurations you want- Parameters:
configurations
- consumer of confiruations to perform on the com.fasterxml.jackson.databind.ObjectMapper
-
JacksonObjectMapper
public JacksonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper om)
-
-
Method Detail
-
getJacksonMapper
public com.fasterxml.jackson.databind.ObjectMapper getJacksonMapper()
-
readValue
public <T> T readValue(java.lang.String value, java.lang.Class<T> valueType)
Description copied from interface:ObjectMapper
reads the content from the request as a string and transforms to a type passed by the asObject method on the Unirest builder.- Specified by:
readValue
in 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:ObjectMapper
reads 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:
readValue
in 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:ObjectMapper
Takes a object and serialize it as a string. This is used to map objects to bodies to pass to requests- Specified by:
writeValue
in interfaceObjectMapper
- Parameters:
value
- the object to serialize to a string- Returns:
- the serialized string of the object
-
-