public final class JacksonUtils extends Object
This class provides utility methods to get a JsonNodeFactory
and
a preconfigured ObjectReader
. It can also be used to return
preconfigured instances of ObjectMapper
(see newMapper()
.
Modifier and Type | Method and Description |
---|---|
static Map<String,JsonNode> |
asMap(JsonNode node)
Return a map out of an object's members
|
static ObjectReader |
getReader()
Return a preconfigured
ObjectReader to read JSON inputs |
static ObjectMapper |
newMapper()
Return a preconfigured
ObjectMapper |
static JsonNodeFactory |
nodeFactory()
Return a preconfigured
JsonNodeFactory to generate JSON data as
JsonNode s |
static String |
prettyPrint(JsonNode node)
Pretty print a JSON value
|
public static ObjectReader getReader()
ObjectReader
to read JSON inputsnewMapper()
public static JsonNodeFactory nodeFactory()
JsonNodeFactory
to generate JSON data as
JsonNode
spublic static Map<String,JsonNode> asMap(JsonNode node)
If the node given as an argument is not a map, an empty map is returned.
node
- the nodepublic static String prettyPrint(JsonNode node)
node
- the JSON value to printnewMapper()
public static ObjectMapper newMapper()
ObjectMapper
The returned mapper will have the following features enabled:
DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS
;JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN
;SerializationFeature.INDENT_OUTPUT
.This returns a new instance each time.
ObjectMapper