Class

play.api.libs.json.Json

WithOptions

Related Doc: package Json

Permalink

final class WithOptions[Opts <: MacroOptions] extends JsonFacade

JSON facade with some macro options.

Opts

the compile-time options

Source
Json.scala
Linear Supertypes
JsonFacade, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. WithOptions
  2. JsonFacade
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new WithOptions()

    Permalink
  2. new WithOptions(config: Aux[Opts])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def arr(items: JsValueWrapper*): JsArray

    Permalink

    Returns a JsArray with given items.

    Returns a JsArray with given items.

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def asciiStringify(json: JsValue): String

    Permalink

    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"
    json

    the JsValue to convert A String with the json representation with all non-ascii characters escaped.

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. val config: Aux[Opts]

    Permalink
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. macro def format[A]: OFormat[A]

    Permalink

    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.

    A

    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]
  13. def fromJson[T](json: JsValue)(implicit fjs: Reads[T]): JsResult[T]

    Permalink

    Converts a JsValue to a value of requested type T.

    Converts a JsValue to a value of requested type T.

    T

    The type of conversion result, only supported if a Reads implicit is available for.

    json

    the JsValue to convert

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. def obj(fields: (String, JsValueWrapper)*): JsObject

    Permalink

    Returns a JsObject with given fields.

    Returns a JsObject with given fields.

    fields

    the object fields specified as pairs of name and value

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  21. def parse(input: Array[Byte]): JsValue

    Permalink

    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

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  22. def parse(input: InputStream): JsValue

    Permalink

    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

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  23. def parse(input: String): JsValue

    Permalink

    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

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  24. def prettyPrint(json: JsValue): String

    Permalink

    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 ]
      }
    }
    json

    the JsValue to convert A String with the json representation.

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  25. macro def reads[A]: Reads[A]

    Permalink

    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.

    A

    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]
  26. def stringify(json: JsValue): String

    Permalink

    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]}}
    json

    the JsValue to convert

    returns

    a String with the json representation

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  28. def toBytes(json: JsValue): Array[Byte]

    Permalink

    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

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  29. def toJsObject[T](o: T)(implicit tjs: OWrites[T]): JsObject

    Permalink

    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.

    T

    the type of the value to be written as JsObject

    o

    the value to convert as JSON object

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  30. def toJson[T](o: T)(implicit tjs: Writes[T]): JsValue

    Permalink

    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.

    T

    the type of the value to be written as JSON

    o

    the value to convert as JSON

    Definition Classes
    WithOptionsJsonFacade
    Annotations
    @inline()
  31. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  32. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. macro def writes[A]: OWrites[A]

    Permalink

    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.

    A

    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]

Inherited from JsonFacade

Inherited from AnyRef

Inherited from Any

Ungrouped