package json4s
- Source
- package.scala
- Alphabetic
- By Inheritance
- json4s
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class CustomKeySerializer[A] extends KeySerializer[A]
- class CustomSerializer[A] extends Serializer[A]
- trait DateFormat extends AnyRef
Conversions between String and Date.
- trait DefaultFormats extends Formats
- final class ExtractableJsonAstNode extends AnyVal
- case class FieldSerializer[A](serializer: PartialFunction[(String, Any), Option[(String, Any)]] = Map(), deserializer: PartialFunction[JField, JField] = Map(), includeLazyVal: Boolean = false)(implicit mf: ClassTag[A]) extends Product with Serializable
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.
- trait Formats extends Serializable
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
- Annotations
- @implicitNotFound()
- case class FullTypeHints(hints: List[Class[_]], typeHintFieldName: String = "jsonClass") extends TypeHints with Product with Serializable
Use full class name as a type hint.
- type JField = (String, json4s.JsonAST.JValue)
- abstract class JsonUtil extends AnyRef
- trait KeySerializer[A] extends AnyRef
- case class MappedTypeHints(hintMap: Map[Class[_], String], typeHintFieldName: String = "jsonClass") extends TypeHints with Product with Serializable
Use a map of keys as type hints.
Use a map of keys as type hints. Values may not be mapped by multiple keys
- type ParameterNameReader = json4s.reflect.ParameterNameReader
- trait RichSerializer[A] extends AnyRef
- trait Serialization extends AnyRef
- trait Serializer[A] extends AnyRef
- case class ShortTypeHints(hints: List[Class[_]], typeHintFieldName: String = "jsonClass") extends TypeHints with Product with Serializable
Use short class name as a type hint.
- trait TypeHints extends AnyRef
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)
- type TypeInfo = json4s.reflect.TypeInfo
Value Members
- val TypeInfo: json4s.reflect.TypeInfo.type
- implicit def convertToJsonInput[A](input: A)(implicit arg0: AsJsonInput[A]): JsonInput
- implicit def jsonwritable[T](a: T)(implicit arg0: Writer[T]): ToJsonWritable[T]
- implicit def jvalue2extractable(jv: JValue): ExtractableJsonAstNode
- implicit def jvalue2monadic(jv: JValue): MonadicJValue
- implicit def jvalue2readerSyntax(j: JValue): ReaderSyntax
- object DefaultFormats extends DefaultFormats
Default date format is UTC time.
- object Extraction
Function to extract values from JSON AST using case classes.
Function to extract values from JSON AST using case classes.
See: ExtractionExamples.scala
- object FieldSerializer extends Serializable
- object Formats extends Serializable
- case object NoTypeHints extends TypeHints with Product with Serializable
Do not use any type hints.