sealed trait JsonFacade extends AnyRef
- Alphabetic
- By Inheritance
- JsonFacade
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def arr(items: JsValueWrapper*): JsArray
Returns a JsArray with given items.
- abstract def asciiStringify(json: JsValue): String
Converts a JsValue to its string representation, escaping all non-ascii characters using
\u005CuXXXX
syntax.Converts a JsValue to its string representation, escaping all non-ascii characters using
\u005CuXXXX
syntax.This is particularly useful when the output JSON will be executed as javascript, since JSON is not a strict subset of javascript (see JSON: The JavaScript subset that isn't).
import play.api.libs.json.{ Json, JsString } Json.asciiStringify(JsString("some\\u005Ctext\\u005C")) // => "some\\u005Ctext\\u005C" Json.stringify(JsString("some\\u005Ctext\\u005C")) // => "sometext"
- json
the JsValue to convert A String with the json representation with all non-ascii characters escaped.
- abstract def fromJson[T](json: JsValue)(implicit fjs: Reads[T]): JsResult[T]
Converts a JsValue to a value of requested type
T
. - abstract def obj(fields: (String, JsValueWrapper)*): JsObject
Returns a JsObject with given fields.
Returns a JsObject with given fields.
- fields
the object fields specified as pairs of name and value
- abstract def parse(input: Array[Byte]): JsValue
Parses some bytes representing a JSON input, and returns it as a JsValue.
Parses some bytes representing a JSON input, and returns it as a JsValue.
The character encoding used will be automatically detected as UTF-8, UTF-16 or UTF-32, as per the heuristics in RFC-4627.
- input
the byte array to parse
- abstract def parse(input: InputStream): JsValue
Parses a stream representing a JSON input, and returns it as a JsValue.
Parses a stream representing a JSON input, and returns it as a JsValue.
- input
the InputStream to parse
- abstract def parse(input: String): JsValue
Parses a String representing a JSON input, and returns it as a JsValue.
Parses a String representing a JSON input, and returns it as a JsValue.
- input
the String to parse
- abstract def prettyPrint(json: JsValue): String
Converts a JsValue to its pretty string representation using default pretty printer (line feeds after each fields and 2-spaces indentation).
Converts a JsValue to its pretty string representation using default pretty printer (line feeds after each fields and 2-spaces indentation).
import play.api.libs.json.Json val res0 = Json.obj( "field1" -> Json.obj( "field11" -> "value11", "field12" -> Json.arr("alpha", 123L) ) ) // => {"field1":{"field11":"value11","field12":["alpha",123]}} Json.prettyPrint(res0) // => // { // "field1" : { // "field11" : "value11", // "field12" : [ "alpha", 123 ] // } // }
- json
the JsValue to convert A String with the json representation.
- abstract def stringify(json: JsValue): String
Converts a JsValue to its string representation.
Converts a JsValue to its string representation.
import play.api.libs.json.Json val input = Json.obj( "field1" -> Json.obj( "field11" -> "value11", "field12" -> Json.arr("alpha", 123L) ) ) Json.stringify(input) // => {"field1":{"field11":"value11","field12":["alpha",123]}}
- json
the JsValue to convert
- returns
a String with the json representation
- abstract def toBytes(json: JsValue): Array[Byte]
Converts a JsValue to bytes (using UTF-8 encoding).
Converts a JsValue to bytes (using UTF-8 encoding).
- json
the JsValue to convert
- returns
an
Array[Byte]
representing the UTF-8-encoded JSON
- abstract def toJsObject[T](o: T)(implicit tjs: OWrites[T]): JsObject
Converts any object writeable value to a JsObject.
- abstract def toJson[T](o: T)(implicit tjs: Writes[T]): JsValue
Converts any writeable value to a JsValue.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()