com.github.fge.jackson
Class JacksonUtils

java.lang.Object
  extended by com.github.fge.jackson.JacksonUtils

public final class JacksonUtils
extends Object

Utility class for Jackson

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().


Method Summary
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 JsonNodes
static String prettyPrint(JsonNode node)
          Pretty print a JSON value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getReader

public static ObjectReader getReader()
Return a preconfigured ObjectReader to read JSON inputs

Returns:
the reader
See Also:
newMapper()

nodeFactory

public static JsonNodeFactory nodeFactory()
Return a preconfigured JsonNodeFactory to generate JSON data as JsonNodes

Returns:
the factory

asMap

public static Map<String,JsonNode> asMap(JsonNode node)
Return a map out of an object's members

If the node given as an argument is not a map, an empty map is returned.

Parameters:
node - the node
Returns:
a map

prettyPrint

public static String prettyPrint(JsonNode node)
Pretty print a JSON value

Parameters:
node - the JSON value to print
Returns:
the pretty printed value as a string
See Also:
newMapper()

newMapper

public static ObjectMapper newMapper()
Return a preconfigured ObjectMapper

The returned mapper will have the following features enabled:

This returns a new instance each time.

Returns:
an ObjectMapper