Json

sealed trait Json[T <: Json[T]] extends JsValue
Companion:
object
trait JsValue
class Object
trait Matchable
class Any
class JsArray
class JsObj

Value members

Abstract methods

def filter(p: (JsPath, JsPrimitive) => Boolean): T

Selects all the values of this Json which satisfy a predicate and are not Jsons. When a Json is found, it is filtered recursively.

Selects all the values of this Json which satisfy a predicate and are not Jsons. When a Json is found, it is filtered recursively.

Value parameters:
p

the predicate uses to test elements. The predicate accepts the path/json.value pair of each element

Returns:

a new Json consisting of all elements of this Json that satisfy the given predicate p.

def filter(p: JsPrimitive => Boolean): T

Selects all the values of this Json which satisfy a predicate and are not Jsons. When a Json is found, it is filtered recursively.

Selects all the values of this Json which satisfy a predicate and are not Jsons. When a Json is found, it is filtered recursively.

Value parameters:
p

the predicate uses to test elements. The predicate accepts the json.value of each element

Returns:

a new Json consisting of all elements of this Json that satisfy the given predicate p.

def filterJsObj(p: (JsPath, JsObj) => Boolean): T

Removes all the Json object of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively (if it passes the filter).

Removes all the Json object of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively (if it passes the filter).

Value parameters:
p

the predicate uses to test the path/object pairs.

Returns:

a new Json consisting of all its elements except those Json object that dont satisfy the given predicate p.

def filterJsObj(p: JsObj => Boolean): T

Removes all the Json object of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively (if it passes the filter).

Removes all the Json object of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively (if it passes the filter).

Value parameters:
p

the predicate uses to test the Json object.

Returns:

a new Json consisting of all its elements except those Json object that dont satisfy the given predicate p.

def filterKeys(p: (JsPath, JsValue) => Boolean): T

Removes all the keys of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively.

Removes all the keys of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively.

Value parameters:
p

the predicate uses to test the path/json.value pairs.

Returns:

a new Json consisting of all array elements of this Json and those key/json.value pairs that satisfy the given predicate p.

def filterKeys(p: String => Boolean): T

Removes all the keys of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively.

Removes all the keys of this Json which dont' satisfy a predicate. When a Json is found, it is filtered recursively.

Value parameters:
p

the predicate uses to test the keys.

Returns:

a new Json consisting of all array elements of this Json and those key/json.value pairs that satisfy the given predicate p.

def flatten: LazyList[(JsPath, JsValue)]
def init: T

The initial part of the Json object without its last element.

The initial part of the Json object without its last element.

def isEmpty: Boolean

returns true if the Json is empty

returns true if the Json is empty

Returns:

true if empty, false otherwise

def map(m: (JsPath, JsPrimitive) => JsValue, p: (JsPath, JsPrimitive) => Boolean): T

Builds a new Json by applying a function to all elements of this Json that are not Json and satisfies a given predicate. When a Json is found, it it mapped recursively.

Builds a new Json by applying a function to all elements of this Json that are not Json and satisfies a given predicate. When a Json is found, it it mapped recursively.

Value parameters:
m

the function to apply to each element. The predicate accepts the path/json.value pair of each element

p

filter to select which elements will be mapped. By default all the elements are selected.

Returns:

a new Json resulting from applying the given map function to each element of this Json that satisfies the filter and collecting the results.

def map(m: JsPrimitive => JsValue): T

Builds a new Json by applying a function to all elements of this Json that are not Json. When a Json is found, it it mapped recursively.

Builds a new Json by applying a function to all elements of this Json that are not Json. When a Json is found, it it mapped recursively.

Value parameters:
m

the function to apply to each element. It accepts the json.value of each element

Returns:

a new Json resulting from applying the given map function to each element of this Json that satisfies the filter and collecting the results.

def mapKeys(m: (JsPath, JsValue) => String, p: (JsPath, JsValue) => Boolean): T

Builds a new Json by applying a function to all the keys of this Json that satisfies a given predicate. If the element associated to a key is a Json, the function is applied recursively,

Builds a new Json by applying a function to all the keys of this Json that satisfies a given predicate. If the element associated to a key is a Json, the function is applied recursively,

Value parameters:
m

the function to apply to each key. It accepts the path/json.value pair as parameters

p

the predicate to select which keys will be mapped

def mapKeys(m: String => String): T

Builds a new Json by applying a function to all the keys of this Json. If the element associated to a key is a Json, the function is applied recursively,

Builds a new Json by applying a function to all the keys of this Json. If the element associated to a key is a Json, the function is applied recursively,

Value parameters:
m

the function to apply to each key. It accepts the key name as a parameter

def reduce[V](p: (JsPath, JsPrimitive) => Boolean, m: (JsPath, JsPrimitive) => V, r: (V, V) => V): Option[V]
def removed(path: JsPath): T

Removes a path from this Json

Removes a path from this Json

Value parameters:
path

the path to be removed

Returns:

If this Json does not contain a binding for path it is returned unchanged. Otherwise, returns a new Json without a binding for path

def serialize(outputStream: OutputStream, writerConfig: WriterConfig): () => Unit
def serialize(config: WriterConfig): Array[Byte]

Serialize this Json into an array of bytes. When possible, it's more efficient to work on byte level that with strings

Serialize this Json into an array of bytes. When possible, it's more efficient to work on byte level that with strings

Returns:

this Json serialized into an array of bytes

def size: Int
def tail: T

The rest of the Json object without its first element.

The rest of the Json object without its first element.

def toPrettyString(config: WriterConfig): String

Converts the string representation of this Json to a pretty print version

Converts the string representation of this Json to a pretty print version

Returns:

pretty print version of the string representation of this Json

override def toString: String

Returns the string representation of this Json

Returns the string representation of this Json

Returns:

the string representation of this Json

Definition Classes
Any
def updated(path: JsPath, value: JsValue, padWith: JsValue): T

Creates a new Json obtained by inserting a given path/json.value pair into this Json. The given element is always inserted at the given path, even if it requires to create new Json or padding arrays.

Creates a new Json obtained by inserting a given path/json.value pair into this Json. The given element is always inserted at the given path, even if it requires to create new Json or padding arrays.

Value parameters:
path

the path

value

the json.value

Returns:

A new Json with the new path/json.value mapping added to this Json.

Concrete methods

@tailrec
final def apply(path: JsPath): JsValue

Returns the element located at a specified path. This function is total on its argument. If no element is found, JsNothing is returned

Returns the element located at a specified path. This function is total on its argument. If no element is found, JsNothing is returned

Value parameters:
path

the path

Returns:

the json value found at the path

def getArray(path: JsPath, default: => JsArray): JsArray
def getArray(path: JsPath): JsArray | Null
def getBigDec(path: JsPath, default: => BigDecimal): BigDecimal
def getBigDec(path: JsPath): BigDecimal | Null
def getBigInt(path: JsPath, default: => BigInt): BigInt
def getBigInt(path: JsPath): BigInt | Null
def getBool(path: JsPath, default: => Boolean): Boolean
def getBool(path: JsPath): Boolean | Null
def getDouble(path: JsPath, default: => Double): Double
def getDouble(path: JsPath): Double | Null
def getInt(path: JsPath, default: => Int): Int
def getInt(path: JsPath): Int | Null
def getLong(path: JsPath, default: => Long): Long
def getLong(path: JsPath): Long | Null
def getObj(path: JsPath, default: => JsObj): JsObj
def getObj(path: JsPath): JsObj | Null
def getStr(path: JsPath, default: => String): String
def getStr(path: JsPath): String | Null
final def nonEmpty: Boolean

returns true if the Json is non empty

returns true if the Json is non empty

Returns:

true if non empty, false otherwise

def serialize(outputStream: OutputStream): () => Unit

Returns a zero-argument function that when called, it serializes this Json into the given output stream, no returning anything

Returns a zero-argument function that when called, it serializes this Json into the given output stream, no returning anything

Value parameters:
outputStream

the output stream

Returns:

() => Unit function that serializes this Json into the given output stream