o

net.liftweb.json

JsonAST

object JsonAST

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
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JsonAST
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait DoubleRenderer extends (Double) ⇒ String

    Parent trait for double renderers, which decide how doubles contained in a JDouble are rendered to JSON string.

  2. case class JArray (arr: List[JValue]) extends JValue with Product with Serializable
  3. case class JBool (value: Boolean) extends JValue with Product with Serializable
  4. case class JDouble (num: Double) extends JValue with Product with Serializable
  5. case class JField (name: String, value: JValue) extends Product with Serializable
  6. case class JInt (num: BigInt) extends JValue with Product with Serializable
  7. case class JObject (obj: List[JField]) extends JValue with Product with Serializable
  8. case class JString (s: String) extends JValue with Product with Serializable
  9. sealed abstract class JValue extends Diffable

    The base type for all things that represent distinct JSON entities in the AST.

    The base type for all things that represent distinct JSON entities in the AST.

    Most members of the AST will extend this class. The one exception is JField which does not extend this class because it really can't properly exist as a first-class citizen of JSON.

  10. case class RenderIntermediaryDocument (value: JValue) extends Product with Serializable
  11. case class RenderSettings (indent: Int, escapeChars: Set[Char] = Set(), spaceAfterFieldName: Boolean = false, doubleRenderer: DoubleRenderer = RenderSpecialDoubleValuesAsNull) extends Product with Serializable

    RenderSettings allows for customizing how JSON is rendered to a String.

    RenderSettings allows for customizing how JSON is rendered to a String. At the moment, you can customize the indentation (if 0, all the JSON is printed on one line), the characters that should be escaped (in addition to a base set that will always be escaped for valid JSON), and whether or not a space should be included after a field name.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def compactRender(value: JValue, appendable: Appendable): String

    Render value to the given appendable using RenderSettings.compact.

  7. def compactRender(value: JValue): String

    Renders JSON directly to string in compact format.

    Renders JSON directly to string in compact format. This is an optimized version of compact(render(value)) when the intermediate Document is not needed.

  8. def concat(values: JValue*): JValue

    Concatenate a sequence of JValues together.

    Concatenate a sequence of JValues together.

    This would be useful in the event that you have a handful of JValue instances that need to be smacked together into one unit.

    For example:

    concat(JInt(1), JInt(2)) == JArray(List(JInt(1), JInt(2)))
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  18. def prettyRender(value: JValue, appendable: Appendable): String

    Render value to the given appendable using RenderSettings.pretty.

  19. def prettyRender(value: JValue): String

    Render value using RenderSettings.pretty.

  20. def render(value: JValue): RenderIntermediaryDocument
  21. def render(value: JValue, settings: RenderSettings, appendable: Appendable = new StringBuilder()): String

    Render value to the given appendable (a StringBuilder, by default) using the given settings.

    Render value to the given appendable (a StringBuilder, by default) using the given settings. The appendable's toString will be called and the result will be returned.

  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. object FailToRenderSpecialDoubleValues extends DoubleRenderer with Product with Serializable

    A DoubleRenderer that throws an IllegalArgumentException when the special values NaN, -Infinity, and Infinity are encountered.

    A DoubleRenderer that throws an IllegalArgumentException when the special values NaN, -Infinity, and Infinity are encountered. Other doubles are rendered normally using toString.

  28. object JNothing extends JValue with Product with Serializable
  29. object JNull extends JValue with Product with Serializable
  30. object JObject extends Product with Serializable
  31. object JValue extends Mergeable
  32. object RenderSettings extends Serializable
  33. object RenderSpecialDoubleValuesAsIs extends DoubleRenderer with Product with Serializable

    A DoubleRenderer that renders special values NaN, -Infinity, and Infinity as-is using toString.

    A DoubleRenderer that renders special values NaN, -Infinity, and Infinity as-is using toString. This is not valid JSON, meaning JSON libraries generally won't be able to parse it (including lift-json!), but JavaScript can eval it. Other double values are also rendered the same way.

    Usage is not recommended.

  34. object RenderSpecialDoubleValuesAsNull extends DoubleRenderer with Product with Serializable

    A DoubleRenderer that renders special values NaN, -Infinity, and Infinity as null.

    A DoubleRenderer that renders special values NaN, -Infinity, and Infinity as null. Other doubles are rendered normally using toString.

Inherited from AnyRef

Inherited from Any

Ungrouped