java.lang.Object
io.jooby.jackson.Jackson2Module
io.jooby.jackson.JacksonModule
- All Implemented Interfaces:
io.jooby.Extension,io.jooby.MessageDecoder,io.jooby.MessageEncoder
Deprecated, for removal: This API element is subject to removal in a future version.
JSON module using Jackson: https://jooby.io/modules/jackson2.
Usage:
{
install(new JacksonModule());
get("/", ctx -> {
MyObject myObject = ...;
// send json
return myObject;
});
post("/", ctx -> {
// read json
MyObject myObject = ctx.body(MyObject.class);
// send json
return myObject;
});
}
For body decoding the client must specify the Content-Type header set to
application/json.
You can retrieve the ObjectMapper via require call:
{
ObjectMapper mapper = require(ObjectMapper.class);
}
Complete documentation is available at: https://jooby.io/modules/jackson2.- Since:
- 2.0.0
- Author:
- edgar
-
Field Summary
Fields inherited from class io.jooby.jackson.Jackson2Module
FILTER_IDFields inherited from interface io.jooby.MessageDecoder
UNSUPPORTED_MEDIA_TYPEFields inherited from interface io.jooby.MessageEncoder
TO_STRING -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Creates a Jackson module using the default object mapper fromcreate(Module...).JacksonModule(com.fasterxml.jackson.databind.ObjectMapper mapper) Deprecated, for removal: This API element is subject to removal in a future version.Creates a Jackson module.JacksonModule(com.fasterxml.jackson.databind.ObjectMapper mapper, io.jooby.MediaType contentType) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.ObjectMappercreate(com.fasterxml.jackson.databind.Module... modules) Deprecated, for removal: This API element is subject to removal in a future version.Default object mapper.Methods inherited from class io.jooby.jackson.Jackson2Module
decode, encode, install, moduleMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jooby.Extension
lateinit
-
Constructor Details
-
JacksonModule
public JacksonModule(com.fasterxml.jackson.databind.ObjectMapper mapper, io.jooby.MediaType contentType) Deprecated, for removal: This API element is subject to removal in a future version. -
JacksonModule
public JacksonModule(com.fasterxml.jackson.databind.ObjectMapper mapper) Deprecated, for removal: This API element is subject to removal in a future version.Creates a Jackson module.- Parameters:
mapper- Object mapper to use.
-
JacksonModule
public JacksonModule()Deprecated, for removal: This API element is subject to removal in a future version.Creates a Jackson module using the default object mapper fromcreate(Module...).
-
-
Method Details
-
create
public static com.fasterxml.jackson.databind.ObjectMapper create(com.fasterxml.jackson.databind.Module... modules) Deprecated, for removal: This API element is subject to removal in a future version.Default object mapper. InstallJdk8Module,JavaTimeModule,ParameterNamesModule.- Parameters:
modules- Extra/additional modules to install.- Returns:
- Object mapper instance.
-
JacksonModuleinstead.