final case class JsObj(map: Map[String, JsValue] = HashMap.empty) extends AbstractJsObj with IterableOnce[(String, JsValue)] with Json[JsObj] with Product with Serializable
represents an immutable Json object. There are several ways of creating a Json object, being the most common the following:
- From a string, array of bytes or an input stream of bytes, using the parse functions of the companion object
- From the apply function of the companion object:
JsObj("a" -> 1, "b" -> "hi", "c" -> JsArray(1,2), "d" -> JsObj("e" -> 1, "f" -> true ) ) // alternative way, from a set of pairs (path,value) JsObj( ("a", 1), ("b", "hi"), ("c" / 0, 1), ("c" / 1, 2), ("d" / "e", 1), ("d" / "f", true) )
- map
immutable map of JsValue
- Alphabetic
- By Inheritance
- JsObj
- Serializable
- Product
- Equals
- Json
- JsValue
- IterableOnce
- AbstractJsObj
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
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 apply(path: JsPath): JsValue
Returns the element located at a specified path.
Returns the element located at a specified path. This function is total on its argument. If no element is found, JsNothing is returned
- path
the path
- returns
the json value found at the path
- Definition Classes
- Json
- def apply(key: String): JsValue
Retrieves the value which is associated with the given key.
Retrieves the value which is associated with the given key. If there is no mapping from the given key to a value,
JsNothing
is returned.- key
the key
- returns
the value associated with the given key
- Definition Classes
- AbstractJsObj
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def containsKey(key: String): Boolean
Tests whether this json object contains a binding for a key.
Tests whether this json object contains a binding for a key.
- key
the key
- returns
true
if there is a binding forkey
in this map,false
otherwise.
- Definition Classes
- AbstractJsObj
- def containsPath(path: JsPath): Boolean
Returns true if there is an element at the specified path
Returns true if there is an element at the specified path
- path
the path
- returns
true if the path exists, false otherwise
- Definition Classes
- Json
- def count(p: ((JsPath, JsValue)) => Boolean = (_: (JsPath, JsValue)) => true): Int
Returns the number of elements that satisfy the given predicate
Returns the number of elements that satisfy the given predicate
- p
the predicate to test each path/value pair
- returns
number of elements that satisfy the predicate
- Definition Classes
- Json
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(that: Any): Boolean
- Definition Classes
- JsObj → Equals → AnyRef → Any
- def exists(p: ((JsPath, JsValue)) => Boolean): Boolean
Tests whether a predicate holds for at least one element of this Json
Tests whether a predicate holds for at least one element of this Json
- p
the predicate to test each path/value pair
- returns
true if the given predicate is satisfied by at least one path/value pair, otherwise false
- Definition Classes
- Json
- def filter(p: (JsPrimitive) => Boolean): JsObj
- Definition Classes
- AbstractJsObj
- def filter(p: (JsPath, JsPrimitive) => Boolean): JsObj
Selects all elements of this Json object which satisfy a predicate.
Selects all elements of this Json object which satisfy a predicate.
- returns
a new Json object consisting of all elements of this Json object that satisfy the given predicate p. The order of the elements is preserved.
- Definition Classes
- AbstractJsObj
- def filterJsObj(p: (JsObj) => Boolean): JsObj
- Definition Classes
- AbstractJsObj
- def filterJsObj(p: (JsPath, JsObj) => Boolean): JsObj
- Definition Classes
- AbstractJsObj
- def filterKeys(p: (String) => Boolean): JsObj
- Definition Classes
- AbstractJsObj
- def filterKeys(p: (JsPath, JsValue) => Boolean): JsObj
- Definition Classes
- AbstractJsObj
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatten: LazyList[(JsPath, JsValue)]
Flatten this Json object into a
LazyList
of pairs of(JsPath,JsValue)
traversing recursively every noe-empty Json found along the way:Flatten this Json object into a
LazyList
of pairs of(JsPath,JsValue)
traversing recursively every noe-empty Json found along the way:val obj = JsObj("a" -> 1, "b" -> "hi", "c" -> JsArray(1,2,), "d" -> JsObj("e" -> 1, "f" -> true ) ) val pairs = obj.toLazyList pairs.foreach { println } //prints out the following: (a,1) (b,"hi") (c/0,1) (c/1,2) (d/e,{}) (d/f,true)
- returns
a
LazyList
of pairs ofJsPath
andJsValue
- Definition Classes
- AbstractJsObj
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def head: (String, JsValue)
Selects the next element of the iterator of this Json object, throwing a NoSuchElementException if the Json object is empty
- def headOption: Option[(String, JsValue)]
Optionally selects the next element of the iterator of this Json object.
Optionally selects the next element of the iterator of this Json object.
- returns
the first element of this Json object if it is nonempty.
None
if it is empty.
- Definition Classes
- AbstractJsObj
- def id: Int
Every implementation of this trait has an unique identifier.
- def init: JsObj
- Definition Classes
- AbstractJsObj
- def inserted(path: JsPath, value: JsValue, padWith: JsValue = JsNull): JsObj
Creates a new Json obtained by inserting a given path/value pair into this Json.
Creates a new Json obtained by inserting a given path/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.
JsObj.empty.inserted(path,value)(path) == value //always true
- path
the path
- value
the value
- returns
A new Json with the new path/value mapping added to this Json.
- def isArr(predicate: (JsArray) => Boolean): Boolean
returns true if this is an array that satisfies a predicate
returns true if this is an array that satisfies a predicate
- predicate
the predicate
- Definition Classes
- JsValue
- def isArr: Boolean
returns true if this is an array
returns true if this is an array
- Definition Classes
- AbstractJsObj
- def isBigDec: Boolean
return false
- def isBigInt: Boolean
return false
- def isBool: Boolean
return false
- def isDecimal(predicate: (BigDecimal) => Boolean): Boolean
returns true if this is a big decimal that satisfies a predicate
returns true if this is a big decimal that satisfies a predicate
- predicate
the predicate
- returns
true if this is a big decimal that satisfies the predicate. If this is a double, it returns false
- Definition Classes
- JsValue
- def isDecimal: Boolean
returns true if this type is a decimal number
- def isDouble: Boolean
return false
- def isDouble(predicate: (Double) => Boolean): Boolean
returns true if this is a double that satisfies a predicate
returns true if this is a double that satisfies a predicate
- predicate
the predicate
- returns
true if this is a double that satisfies the predicate
- Definition Classes
- JsValue
- def isEmpty: Boolean
Tests whether the Json object is empty.
Tests whether the Json object is empty.
- returns
true
if the Json object contains no elements,false
otherwise.
- Definition Classes
- AbstractJsObj
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isInt: Boolean
return false
- def isInt(predicate: (Int) => Boolean): Boolean
returns true if this is an integer that satisfies a predicate
returns true if this is an integer that satisfies a predicate
- predicate
the predicate
- Definition Classes
- JsValue
- def isIntegral(predicate: (BigInt) => Boolean): Boolean
returns true if this is a big integer that satisfies a predicate
returns true if this is a big integer that satisfies a predicate
- predicate
the predicate
- returns
true if this is a big integer that satisfies the predicate. If this is either an integer or a long, it returns false.
- Definition Classes
- JsValue
- def isIntegral: Boolean
returns true if this type is an integral number
returns true if this type is an integral number
- returns
isInt || isLong || isBigInt
- Definition Classes
- JsValue
- def isJson(predicate: (Json[_]) => Boolean): Boolean
returns true if this is a json that satisfy a predicate
returns true if this is a json that satisfy a predicate
- predicate
the predicate
- Definition Classes
- JsValue
- def isJson: Boolean
returns true is this type is an array or an object
returns true is this type is an array or an object
- Definition Classes
- JsValue
- def isLong: Boolean
return false
- def isLong(predicate: (Long) => Boolean): Boolean
returns true if this is a long that satisfies a predicate
returns true if this is a long that satisfies a predicate
- predicate
the predicate
- returns
true if this is a long that satisfies the predicate and false otherwise. If this is an integer, it returns false.
- Definition Classes
- JsValue
- def isNotEmpty: Boolean
- Definition Classes
- Json
- def isNotJson: Boolean
returns true if this is neither an object nor an array
returns true if this is neither an object nor an array
- Definition Classes
- JsValue
- def isNotNull: Boolean
returns true if this is not null
returns true if this is not null
- returns
true if this is not null, false otherwise
- Definition Classes
- JsValue
- def isNotNumber: Boolean
returns true if this is not a number
returns true if this is not a number
- Definition Classes
- JsValue
- def isNothing: Boolean
return false
- def isNull: Boolean
return false
- def isNumber: Boolean
return false
- def isObj(predicate: (JsObj) => Boolean): Boolean
returns true if this is an object that satisfies a predicate
returns true if this is an object that satisfies a predicate
- predicate
the predicate
- Definition Classes
- JsValue
- def isObj: Boolean
returns true if this is an object
returns true if this is an object
- Definition Classes
- AbstractJsObj
- def isStr: Boolean
return false
- def isStr(predicate: (String) => Boolean): Boolean
returns true if this is a string that satisfies a predicate
returns true if this is a string that satisfies a predicate
- predicate
the predicate
- Definition Classes
- JsValue
- def iterator: Iterator[(String, JsValue)]
Returns an iterator of this Json object.
Returns an iterator of this Json object. Can be used only once
- returns
an iterator
- Definition Classes
- AbstractJsObj
- def keySet: Set[String]
Collects all keys of this map in a set.
Collects all keys of this map in a set.
- returns
a set containing all keys of this map.
- Definition Classes
- AbstractJsObj
- def keys: Iterable[String]
Collects all keys of this Json object in an iterable collection.
Collects all keys of this Json object in an iterable collection.
- returns
the keys of this Json object as an iterable.
- Definition Classes
- AbstractJsObj
- def knownSize: Int
- Definition Classes
- IterableOnce
- def last: (String, JsValue)
Selects the last element of the iterator of this Json object, throwing a NoSuchElementException if the Json object is empty
Selects the last element of the iterator of this Json object, throwing a NoSuchElementException if the Json object is empty
- returns
the last element of the iterator of this Json object.
- Definition Classes
- AbstractJsObj
- def lastOption: Option[(String, JsValue)]
Optionally selects the last element of the iterator of this Json object.
Optionally selects the last element of the iterator of this Json object.
- returns
the last element of the iterator of this Json object,
None
if it is empty.
- Definition Classes
- AbstractJsObj
- def map[J <: JsValue](m: (JsPath, JsPrimitive) => J, p: (JsPath, JsPrimitive) => Boolean = (_, _) => true): JsObj
- Definition Classes
- AbstractJsObj
- def map[J <: JsValue](m: (JsPrimitive) => J): JsObj
- Definition Classes
- AbstractJsObj
- def mapKeys(m: (String) => String): JsObj
- Definition Classes
- AbstractJsObj
- def mapKeys(m: (JsPath, JsValue) => String, p: (JsPath, JsValue) => Boolean = (_, _) => true): JsObj
- Definition Classes
- AbstractJsObj
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- 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
- Definition Classes
- Json
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def reduce[V](p: (JsPath, JsPrimitive) => Boolean = (_, _) => true, m: (JsPath, JsPrimitive) => V, r: (V, V) => V): Option[V]
- Definition Classes
- AbstractJsObj
- def removed(path: JsPath): JsObj
Removes a path from this Json
- def removedAll(xs: IterableOnce[JsPath]): JsObj
Creates a new Json from this Json by removing all paths of another collection
- def serialize: Array[Byte]
Serialize this Json into an array of bytes.
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
- Definition Classes
- Json
- 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
- outputStream
the output stream
- returns
() => Unit function that serializes this Json into the given output stream
- Definition Classes
- Json
- def size: Int
The size of this Json object.
The size of this Json object. *
- returns
the number of elements in this Json object.
- Definition Classes
- AbstractJsObj
- def stepper[S <: Stepper[_]](implicit shape: StepperShape[(String, JsValue), S]): S
- Definition Classes
- IterableOnce
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tail: JsObj
- Definition Classes
- AbstractJsObj
- def toJsArray: JsArray
Throws an UserError exception
Throws an UserError exception
- returns
Throws an UserError exception
- Definition Classes
- AbstractJsObj
- def toJsBigDec: JsBigDec
throws an UserError exception
- def toJsBigInt: JsBigInt
throws an UserError exception
- def toJsBool: JsBool
throws an UserError exception
- def toJsDouble: JsDouble
throws an UserError exception
- def toJsInt: JsInt
throws an UserError exception
- def toJsLong: JsLong
throws an UserError exception
- def toJsNull: JsNull.type
throws an UserError exception
- def toJsNumber: JsNumber
throws an UserError exception
- def toJsObj: JsObj
Returns this Json object
- def toJsStr: JsStr
throws an UserError exception
- def toJson: Json[_]
Returns this Json object as a
Json
- def toPrettyString: 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
- Definition Classes
- Json
- def toString(): String
string representation of this Json array.
- def validate(spec: JsObjSpec): LazyList[(JsPath, Invalid)]
- 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()