play.libs
Class Json

java.lang.Object
  extended by play.libs.Json

public class Json
extends java.lang.Object

Helper functions to handle JsonNode values.


Constructor Summary
Json()
           
 
Method Summary
static
<A> A
fromJson(com.fasterxml.jackson.databind.JsonNode json, java.lang.Class<A> clazz)
          Convert a JsonNode to a Java value
static com.fasterxml.jackson.databind.node.ObjectNode newObject()
          Creates a new empty ObjectNode.
static com.fasterxml.jackson.databind.JsonNode parse(java.io.InputStream src)
          Parse a InputStream representing a json, and return it as a JsonNode.
static com.fasterxml.jackson.databind.JsonNode parse(java.lang.String src)
          Parse a String representing a json, and return it as a JsonNode.
static void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
          Inject the object mapper to use.
static java.lang.String stringify(com.fasterxml.jackson.databind.JsonNode json)
          Convert a JsonNode to its string representation.
static com.fasterxml.jackson.databind.JsonNode toJson(java.lang.Object data)
          Convert an object to JsonNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Json

public Json()
Method Detail

toJson

public static com.fasterxml.jackson.databind.JsonNode toJson(java.lang.Object data)
Convert an object to JsonNode.

Parameters:
data - Value to convert in Json.

fromJson

public static <A> A fromJson(com.fasterxml.jackson.databind.JsonNode json,
                             java.lang.Class<A> clazz)
Convert a JsonNode to a Java value

Parameters:
json - Json value to convert.
clazz - Expected Java value type.

newObject

public static com.fasterxml.jackson.databind.node.ObjectNode newObject()
Creates a new empty ObjectNode.


stringify

public static java.lang.String stringify(com.fasterxml.jackson.databind.JsonNode json)
Convert a JsonNode to its string representation.


parse

public static com.fasterxml.jackson.databind.JsonNode parse(java.lang.String src)
Parse a String representing a json, and return it as a JsonNode.


parse

public static com.fasterxml.jackson.databind.JsonNode parse(java.io.InputStream src)
Parse a InputStream representing a json, and return it as a JsonNode.


setObjectMapper

public static void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
Inject the object mapper to use. 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 plugin or from Global.onStart.