Returns a JsArray with given items.
Returns a JsArray with given items.
Converts a JsValue to its string representation,
escaping all non-ascii characters using \uXXXX
syntax.
Converts a JsValue to its string representation,
escaping all non-ascii characters using \uXXXX
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).
scala> Json.asciiStringify(JsString("some\u2028text\u2029")) res0: String = "some\u2028text\u2029" scala> Json.stringify(JsString("some\u2028text\u2029")) res1: String = "sometext"
the JsValue to convert A String with the json representation with all non-ascii characters escaped.
Creates a OFormat[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
Creates a OFormat[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
If any missing implicit is discovered, compiler will break with corresponding error.
the type for which the handler must be materialized
import play.api.libs.json.Json case class User(userName: String, age: Int) implicit val userFormat: OFormat[User] = Json.using[Json.WithDefaultValues].format[User]
Converts a JsValue to a value of requested type T
.
Converts a JsValue to a value of requested type T
.
The type of conversion result, only supported if a Reads implicit is available for.
the JsValue to convert
Returns a JsObject with given fields.
Returns a JsObject with given fields.
the object fields specified as pairs of name and value
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.
the byte array to parse
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.
the InputStream to parse
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.
the String to parse
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).
scala> Json.stringify(Json.obj( "field1" -> Json.obj( "field11" -> "value11", "field12" -> Json.arr("alpha", 123L) ) )) res0: String = {"field1":{"field11":"value11","field12":["alpha",123]}} scala> Json.prettyPrint(res0) res1: String = { "field1" : { "field11" : "value11", "field12" : [ "alpha", 123 ] } }
the JsValue to convert A String with the json representation.
Creates a Reads[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
Creates a Reads[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
If any missing implicit is discovered, compiler will break with corresponding error.
the type for which the handler must be materialized
import play.api.libs.json.Json case class User(userName: String, age: Int) implicit val userReads: Reads[User] = Json.using[Json.MacroOptions with Json.DefaultValues].reads[User]
Converts a JsValue to its string representation.
Converts a JsValue to its string representation.
scala> Json.stringify(Json.obj( "field1" -> Json.obj( "field11" -> "value11", "field12" -> Json.arr("alpha", 123L) ) )) res0: String = {"field1":{"field11":"value11","field12":["alpha",123]}} scala> Json.stringify(res0) res1: String = {"field1":{"field11":"value11","field12":["alpha",123]}}
the JsValue to convert
a String with the json representation
Converts a JsValue to bytes (using UTF-8 encoding).
Converts a JsValue to bytes (using UTF-8 encoding).
the JsValue to convert
an Array[Byte]
representing the UTF-8-encoded JSON
Converts any object writeable value to a JsObject.
Converts any object writeable value to a JsObject.
A value is writeable as an object, if a OWrites implicit is available for its type.
the type of the value to be written as JsObject
the value to convert as JSON object
Converts any writeable value to a JsValue.
Converts any writeable value to a JsValue.
A value is writeable if a Writes implicit is available for its type.
the type of the value to be written as JSON
the value to convert as JSON
Creates a OWrites[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
Creates a OWrites[T]
by resolving, at compile-time,
the case class fields or sealed family, and the required implicits.
If any missing implicit is discovered, compiler will break with corresponding error.
the type for which the handler must be materialized
import play.api.libs.json.Json case class User(userName: String, age: Int) implicit val userWrites: OWrites[User] = Json.using[Json.MacroOptions].writes[User]
JSON facade with some macro options.
the compile-time options