ReaderSyntax
Attributes
- Source
- ReaderSyntax.scala
- Graph
-
- Supertypes
-
class AnyValtrait Matchableclass Any
Members list
Value members
Concrete methods
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type A
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type A
Example:
case class Person(name: String)
implicit object PersonReader extends Reader[Person] {
def read(json: JValue): Person = Person((json \ "name").extract[String])
}
JObject(JField("name", JString("Joe")) :: Nil).as[Person]
Attributes
- Source
- ReaderSyntax.scala
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type Option[A]
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type Option[A]
Example:
case class Person(name: String)
implicit object PersonReader extends Reader[Person] {
def read(json: JValue): Person = Person((json \ "name").extract[String])
}
JObject(JField("name", JString("Joe")) :: Nil).getAs[Person]
Attributes
- Source
- ReaderSyntax.scala
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type A if an error occurs it will return the default value.
Given that an implicit reader of type A is in scope It will deserialize the org.json4s.JValue to an object of type A if an error occurs it will return the default value.
Example:
case class Person(name: String)
implicit object PersonReader extends Reader[Person] {
def read(json: JValue): Person = Person((json \ "name").extract[String])
}
JObject(JField("name", JString("Joe")) :: Nil).getAsOrElse(Person("Tom"))
Attributes
- Source
- ReaderSyntax.scala