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.
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.
Render value
to the given appendable
using RenderSettings.compact
.
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.
Concatenate a sequence of JValue
s together.
Concatenate a sequence of JValue
s 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)))
Render value
to the given appendable
using RenderSettings.pretty
.
Render value
using RenderSettings.pretty
.
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.
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:Once serialized to the string representation of JSON you would end up with the following: