WithOptions
JSON facade with some macro options.
Type parameters
- Opts
-
the compile-time options
Attributes
- Graph
-
- Supertypes
Members list
Value members
Constructors
Concrete methods
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"
$jsonParam $returnStringRepr with all non-ascii characters escaped.
Attributes
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.
Value parameters
- input
-
the byte array to parse
Attributes
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 ]
// }
// }
$jsonParam $returnStringRepr.
Attributes
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]}}
$jsonParam
Attributes
- Returns
-
a String with the json representation
Converts any object writeable value to a JsObject.
Inherited methods
Attributes
- Inherited from:
- JsMacrosWithOptions
Attributes
- Inherited from:
- JsMacrosWithOptions
Attributes
- Inherited from:
- JsMacrosWithOptions