Conversions between String and Date.
A difference between two JSONs (j1 diff j2).
A difference between two JSONs (j1 diff j2).
what has changed from j1 to j2
what has been added to j2
what has been deleted from j1
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") )
Formats to use when converting JSON.
Formats to use when converting JSON. Formats are usually configured by using an implicit parameter:
implicit val formats = net.liftweb.json.DefaultFormats
Use full class name as a type hint.
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 = DefaultFormats.withHints(hints)
Default date format is UTC time.
Computes a diff between two JSONs.
Function to extract values from JSON AST using case classes.
Function to extract values from JSON AST using case classes.
See: ExtractionExamples.scala
Basic implicit conversions from primitive types into JSON.
Basic implicit conversions from primitive types into JSON. Example:
import net.liftweb.json.Implicits._ JObject(JField("name", "joe") :: Nil) == JObject(JField("name", JString("joe")) :: Nil)
A DSL to produce valid JSON.
A DSL to produce valid JSON. Example:
import net.liftweb.json.JsonDSL._ ("name", "joe") ~ ("age", 15) == JObject(JField("name",JString("joe")) :: JField("age",JInt(15)) :: Nil)
JSON parser.
Function to merge two JSONs.
Do not use any type hints.
Printer converts JSON to String.
Printer converts JSON to String.
Before printing a JValue
needs to be rendered into scala.text.Document.
Example:
pretty(render(json))
net.liftweb.json.JsonAST#render
Functions to serialize and deserialize a case class.
Functions to serialize and deserialize a case class. Custom serializer can be inserted if a class is not a case class.
Example:
val hints = new ShortTypeHints( ... ) implicit val formats = Serialization.formats(hints)
net.liftweb.json.TypeHints
Functions to convert between JSON and XML.