public class JacksonModule extends AbstractModule
JsonRenderer
, a renderer for Jackson
object.
Also provides a default instance of ObjectMapper
, which is the engine for serialization, and an
instance of ObjectWriter
derived from this which is used by the JsonRenderer
implementation.
To globally customize JSON generation, It is usually sufficient to override the ObjectMapper
binding.
Constructor and Description |
---|
JacksonModule()
Constructor.
|
JacksonModule(boolean prettyPrint)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configure() |
boolean |
isPrettyPrint()
Should the JSON be pretty printed.
|
protected ObjectReader |
objectReader(ObjectMapper objectMapper) |
protected ObjectWriter |
objectWriter(ObjectMapper objectMapper) |
void |
setPrettyPrint(boolean prettyPrint)
Sets if the JSON should be pretty printed.
|
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
public JacksonModule()
public JacksonModule(boolean prettyPrint)
prettyPrint
- initial pretty print value.public boolean isPrettyPrint()
Default is false
.
public void setPrettyPrint(boolean prettyPrint)
See DefaultPrettyPrinter
for formatting details.
prettyPrint
- If the JSON should be pretty printedprotected void configure()
configure
in class AbstractModule
@Provides @Singleton protected ObjectWriter objectWriter(ObjectMapper objectMapper)
@Provides @Singleton protected ObjectReader objectReader(ObjectMapper objectMapper)