Conversions between String and Date.
Serializer which serializes all fields of a class too.
Serializer which serializes all fields of a class too.
Serialization can be intercepted by giving two optional PartialFunctions as constructor parameters:
FieldSerializer[WildDog]( renameTo("name", "animalname") orElse ignore("owner"), renameFrom("animalname", "name") )
The third optional parameter "includeLazyVal" determines if serializer will serialize/deserialize lazy val fields or not.
Formats to use when converting JSON.
Formats to use when converting JSON. Formats are usually configured by using an implicit parameter:
implicit val formats: Formats = org.json4s.DefaultFormats
Use full class name as a type hint.
Use a map of keys as type hints.
Use a map of keys as type hints. Values may not be mapped by multiple keys
Use short class name as a type hint.
Type hints can be used to alter the default conversion rules when converting Scala instances into JSON and vice versa.
Type hints can be used to alter the default conversion rules when converting Scala instances into JSON and vice versa. Type hints must be used when converting class which is not supported by default (for instance when class is not a case class).
Example:
class DateTime(val time: Long) val hints = new ShortTypeHints(classOf[DateTime] :: Nil) { override def serialize: PartialFunction[Any, JObject] = { case t: DateTime => JObject(JField("t", JInt(t.time)) :: Nil) } override def deserialize: PartialFunction[(String, JObject), Any] = { case ("DateTime", JObject(JField("t", JInt(t)) :: Nil)) => new DateTime(t.longValue) } } implicit val formats: Formats = DefaultFormats.withHints(hints)
Default date format is UTC time.
Function to extract values from JSON AST using case classes.
Function to extract values from JSON AST using case classes.
See: ExtractionExamples.scala
Do not use any type hints.