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]
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]
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"))