package json
- Alphabetic
- By Inheritance
- json
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class CustomSerializer [A] extends Serializer[A]
-
trait
DateFormat
extends AnyRef
Conversions between String and Date.
- trait DefaultFormats extends Formats
-
case class
Diff
(changed: JValue, added: JValue, deleted: JValue) extends Product with Serializable
A difference between two JSONs (j1 diff j2).
A difference between two JSONs (j1 diff j2).
- changed
what has changed from j1 to j2
- added
what has been added to j2
- deleted
what has been deleted from j1
-
case class
FieldSerializer
[A](serializer: PartialFunction[(String, Any), Option[(String, Any)]] = Map(), deserializer: PartialFunction[JField, JField] = Map())(implicit evidence$1: Manifest[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") )
-
trait
Formats
extends AnyRef
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
-
case class
FullTypeHints
(hints: List[Class[_]]) extends TypeHints with Product with Serializable
Use full class name as a type hint.
- trait Implicits extends AnyRef
- type JArray = json.JsonAST.JArray
- type JBool = json.JsonAST.JBool
- type JDouble = json.JsonAST.JDouble
- type JField = json.JsonAST.JField
- type JInt = json.JsonAST.JInt
- type JObject = json.JsonAST.JObject
- type JString = json.JsonAST.JString
- type JValue = json.JsonAST.JValue
- trait JsonDSL extends Implicits
- case class MappingException (msg: String, cause: Exception) extends Exception with Product with Serializable
- trait ParameterNameReader extends AnyRef
- trait Serializer [A] extends AnyRef
-
case class
ShortTypeHints
(hints: List[Class[_]]) 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 = DefaultFormats.withHints(hints)
- case class TypeInfo (clazz: Class[_], parameterizedType: Option[ParameterizedType]) extends Product with Serializable
Value Members
- val JArray: json.JsonAST.JArray.type
- val JBool: json.JsonAST.JBool.type
- val JDouble: json.JsonAST.JDouble.type
- val JField: json.JsonAST.JField.type
- val JInt: json.JsonAST.JInt.type
- val JNothing: json.JsonAST.JNothing.type
- val JNull: json.JsonAST.JNull.type
- val JObject: json.JsonAST.JObject.type
- val JString: json.JsonAST.JString.type
- def compactRender(value: JValue): String
- def parse(s: String): JValue
- def parseOpt(s: String): Option[JValue]
- def prettyRender(value: JValue): String
-
object
DefaultFormats
extends DefaultFormats
Default date format is UTC time.
-
object
Diff
extends Serializable
Computes a diff between two JSONs.
-
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
Implicits
extends Implicits
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)
-
object
JsonAST
This object contains the abstract syntax tree (or AST) for working with JSON objects in lift-json.
This object contains the abstract syntax tree (or AST) for working with JSON objects in lift-json.
The purpose of the JSON AST is to represent and manipulate JSON by leveraging Scala language features like types, case classes, etc. The AST should allow you to represent anything you could imagine from JSON land using the Scala type system.
Everything in the AST has a single root: JValue. A JValue could, quite literally, be anything. It could be an an object (represented by
JObject
), a string (JString
), a null (JNull
), and so on. So, when constructing a JSON object with the AST directly you might construct something like the following:JObject(JField("bacon", JBool(true)) :: JField("spinach", JBool(false)))
Once serialized to the string representation of JSON you would end up with the following:
{ "bacon":true, "spinach":false }
-
object
JsonDSL
extends JsonDSL
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)
-
object
JsonParser
JSON parser.
-
object
Merge
Function to merge two JSONs.
-
object
NoTypeHints
extends TypeHints with Product with Serializable
Do not use any type hints.
-
object
Serialization
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)
- See also
net.liftweb.json.TypeHints
-
object
Xml
Functions to convert between JSON and XML.