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
}- Alphabetic
- By Inheritance
- JsonAST
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait DoubleRenderer extends (Double) => String
Parent trait for double renderers, which decide how doubles contained in a JDouble are rendered to JSON string.
- case class JArray(arr: List[JValue]) extends JValue with Product with Serializable
- case class JBool(value: Boolean) extends JValue with Product with Serializable
- case class JDouble(num: Double) extends JValue with Product with Serializable
- case class JField(name: String, value: JValue) extends Product with Serializable
- case class JInt(num: BigInt) extends JValue with Product with Serializable
- case class JObject(obj: List[JField]) extends JValue with Product with Serializable
- case class JString(s: String) extends JValue with Product with Serializable
- 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
JFieldwhich does not extend this class because it really can't properly exist as a first-class citizen of JSON. - case class RenderIntermediaryDocument(value: JValue) extends Product with Serializable
- case class RenderSettings(indent: Int, escapeChars: Set[Char] = Set.empty, 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def compactRender(value: JValue, appendable: Appendable): String
Render
valueto the givenappendableusingRenderSettings.compact. - 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.
- 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
JValueinstances that need to be smacked together into one unit.For example:
concat(JInt(1), JInt(2)) == JArray(List(JInt(1), JInt(2)))
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def prettyRender(value: JValue, appendable: Appendable): String
Render
valueto the givenappendableusingRenderSettings.pretty. - def prettyRender(value: JValue): String
Render
valueusingRenderSettings.pretty. - def render(value: JValue): RenderIntermediaryDocument
- def render(value: JValue, settings: RenderSettings, appendable: Appendable = new StringBuilder()): String
Render
valueto the givenappendable(aStringBuilder, by default) using the givensettings.Render
valueto the givenappendable(aStringBuilder, by default) using the givensettings. The appendable'stoStringwill be called and the result will be returned. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- case object FailToRenderSpecialDoubleValues extends DoubleRenderer with Product with Serializable
A
DoubleRendererthat throws anIllegalArgumentExceptionwhen the special valuesNaN,-Infinity, andInfinityare encountered.A
DoubleRendererthat throws anIllegalArgumentExceptionwhen the special valuesNaN,-Infinity, andInfinityare encountered. Other doubles are rendered normally usingtoString. - case object JNothing extends JValue with Product with Serializable
- case object JNull extends JValue with Product with Serializable
- case object JObject extends Product with Serializable
- object JValue extends Mergeable
- object RenderSettings extends Serializable
- case object RenderSpecialDoubleValuesAsIs extends DoubleRenderer with Product with Serializable
A
DoubleRendererthat renders special valuesNaN,-Infinity, andInfinityas-is usingtoString.A
DoubleRendererthat renders special valuesNaN,-Infinity, andInfinityas-is usingtoString. 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.
- case object RenderSpecialDoubleValuesAsNull extends DoubleRenderer with Product with Serializable
A
DoubleRendererthat renders special valuesNaN,-Infinity, andInfinityasnull.A
DoubleRendererthat renders special valuesNaN,-Infinity, andInfinityasnull. Other doubles are rendered normally usingtoString.