public class Json extends Object
Constructor and Description |
---|
Json() |
Modifier and Type | Method and Description |
---|---|
static String |
asciiStringify(com.fasterxml.jackson.databind.JsonNode json)
Converts a JsonNode to its string representation, escaping non-ascii characters.
|
static <A> A |
fromJson(com.fasterxml.jackson.databind.JsonNode json,
Class<A> clazz)
Converts a JsonNode to a Java value
|
static com.fasterxml.jackson.databind.ObjectMapper |
mapper()
Gets the ObjectMapper used to serialize and deserialize objects to and from JSON values.
|
static com.fasterxml.jackson.databind.node.ArrayNode |
newArray()
Creates a new empty ArrayNode.
|
static com.fasterxml.jackson.databind.ObjectMapper |
newDefaultMapper()
Deprecated.
Deprecated as of 2.8.0. Inject an
ObjectMapper instead. |
static com.fasterxml.jackson.databind.node.ObjectNode |
newObject()
Creates a new empty ObjectNode.
|
static com.fasterxml.jackson.databind.JsonNode |
parse(byte[] src)
Parses a byte array representing a json, and return it as a JsonNode.
|
static com.fasterxml.jackson.databind.JsonNode |
parse(InputStream src)
Parses a InputStream representing a json, and return it as a JsonNode.
|
static com.fasterxml.jackson.databind.JsonNode |
parse(String src)
Parses a String representing a json, and return it as a JsonNode.
|
static String |
prettyPrint(com.fasterxml.jackson.databind.JsonNode json)
Converts a JsonNode to its string representation.
|
static void |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Inject the object mapper to use.
|
static String |
stringify(com.fasterxml.jackson.databind.JsonNode json)
Converts a JsonNode to its string representation.
|
static com.fasterxml.jackson.databind.JsonNode |
toJson(Object data)
Converts an object to JsonNode.
|
@Deprecated public static com.fasterxml.jackson.databind.ObjectMapper newDefaultMapper()
ObjectMapper
instead.ObjectMapper
with the default configuration for Play.ObjectMapper
with some modules enabled.public static com.fasterxml.jackson.databind.ObjectMapper mapper()
This can be set to a custom implementation using Json.setObjectMapper.
public static com.fasterxml.jackson.databind.JsonNode toJson(Object data)
data
- Value to convert in Json.public static <A> A fromJson(com.fasterxml.jackson.databind.JsonNode json, Class<A> clazz)
A
- the type of the return value.json
- Json value to convert.clazz
- Expected Java value type.public static com.fasterxml.jackson.databind.node.ObjectNode newObject()
public static com.fasterxml.jackson.databind.node.ArrayNode newArray()
public static String stringify(com.fasterxml.jackson.databind.JsonNode json)
json
- the JSON node to convert.public static String asciiStringify(com.fasterxml.jackson.databind.JsonNode json)
json
- the JSON node to convert.public static String prettyPrint(com.fasterxml.jackson.databind.JsonNode json)
json
- the JSON node to convert.public static com.fasterxml.jackson.databind.JsonNode parse(String src)
src
- the JSON string.public static com.fasterxml.jackson.databind.JsonNode parse(InputStream src)
src
- the JSON input stream.public static com.fasterxml.jackson.databind.JsonNode parse(byte[] src)
src
- the JSON input bytes.public static void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
This is intended to be used when Play starts up. By default, Play will inject its own object mapper here, but this mapper can be overridden either by a custom module.
mapper
- the object mapper.