org.json4s

package org.json4s

Type members

Classlikes

class CustomKeySerializer[A](ser: Formats => (PartialFunction[String, A], PartialFunction[Any, String]))(`evidence$1`: ClassTag[A]) extends KeySerializer[A]
class CustomSerializer[A](ser: Formats => (PartialFunction[JValue, A], PartialFunction[Any, JValue]))(`evidence$1`: ClassTag[A]) extends Serializer[A]
trait DateFormat

Conversions between String and Date.

Conversions between String and Date.

Default date format is UTC time.

Default date format is UTC time.

Companion
class
trait DefaultFormats extends Formats
Companion
object
final class ExtractableJsonAstNode(jv: JValue) extends AnyVal
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

case class FieldSerializer[A](serializer: PartialFunction[(String, Any), Option[(String, Any)]], deserializer: PartialFunction[JField, JField], includeLazyVal: Boolean)(mf: ClassTag[A])

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.

Companion
object
Companion
class
object Formats
Companion
class
@implicitNotFound("No org.json4s.Formats found. Try to bring an instance of org.json4s.Formats in scope or use the org.json4s.DefaultFormats.")
trait Formats extends Serializable

Formats to use when converting JSON. Formats are usually configured by using an implicit parameter:

Formats to use when converting JSON. Formats are usually configured by using an implicit parameter:

implicit val formats: Formats = org.json4s.DefaultFormats
Companion
object
case class FullTypeHints(hints: List[Class[_]], typeHintFieldName: String) extends TypeHints

Use full class name as a type hint.

Use full class name as a type hint.

abstract class JsonUtil(fmts: Formats)
trait KeySerializer[A]
case class MappedTypeHints(hintMap: Map[Class[_], String], typeHintFieldName: String) extends TypeHints

Use a map of keys as type hints. Values may not be mapped by multiple keys

Use a map of keys as type hints. Values may not be mapped by multiple keys

case object NoTypeHints extends TypeHints

Do not use any type hints.

Do not use any type hints.

trait RichSerializer[A]
trait Serializer[A]
case class ShortTypeHints(hints: List[Class[_]], typeHintFieldName: String) extends TypeHints

Use short class name as a type hint.

Use short class name as a type hint.

trait TypeHints

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).

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)

Value members

Concrete fields

val TypeInfo: TypeInfo

Implicits

Implicits

implicit def convertToJsonInput[A](input: A)(`evidence$1`: AsJsonInput[A]): JsonInput
implicit def jsonwritable[T](a: T)(`evidence$2`: Writer[T]): ToJsonWritable[T]
implicit def jvalue2extractable(jv: JValue): ExtractableJsonAstNode
implicit def jvalue2monadic(jv: JValue): MonadicJValue
implicit def jvalue2readerSyntax(j: JValue): ReaderSyntax