JsonValue
Represents JSON value.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait JsonBooleanobject False.typeobject True.typeobject JsonNull.typetrait JsonNumbertrait JsonStringtrait JsonStructuretrait JsonArrayclass JsonStructureFacadetrait JsonObjectShow all
Members list
Value members
Concrete methods
Concatenates JSON object.
Concatenates JSON object.
Attributes
- Returns
-
new JSON object
Concatenates JSON array.
Concatenates JSON array.
Attributes
- Returns
-
new JSON array
Prepends value.
Prepends value.
Attributes
- Returns
-
new JSON array
Appends value.
Appends value.
Attributes
- Returns
-
new JSON array
Gets value in JSON object.
Gets value in JSON object.
Value parameters
- key
-
object key
Attributes
- Throws
-
ClassCastException
if not JsonObject
Gets value in JSON array.
Gets value in JSON array.
Value parameters
- index
-
array index
Attributes
- Throws
-
ClassCastException
if not JsonArray
Collects values with given object key while traversing nested objects and arrays.
Collects values with given object key while traversing nested objects and arrays.
import grapple.json.{ Json, \\, given }
val json = Json.parse("""{
"node": {
"name": "localhost",
"users": [
{ "id": 0, "name": "root" },
{ "id": 1000, "name": "lupita" }
]
}
}""")
val names = (json \\ "name").map(_.as[String])
assert { names == Seq("localhost", "root", "lupita") }
Value parameters
- key
-
object key
Attributes
Gets value.
Gets value.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.util.NoSuchElementException
if key does not exist
Gets value.
Gets value.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
Converts value.
Converts value.
Value parameters
- input
-
converter
Attributes
Gets object fields.
Gets object fields.
Attributes
Optionally gets value.
Optionally gets value.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.util.NoSuchElementException
if key does not exist
Gets object keys.
Gets object keys.
Attributes
Removes field.
Removes field.
Value parameters
- key
-
object key
Attributes
- Returns
-
new JSON object
Removes value at given index.
Removes value at given index.
Value parameters
- index
-
array index
Attributes
- Returns
-
new JSON array
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
- Note
-
Subsequent values to index are shifted left.
Gets size.
Gets size.
Attributes
Unwraps underlying JSON structure.
Unwraps underlying JSON structure.
Attributes
Adds or updates field.
Adds or updates field.
Value parameters
- key
-
object key
- value
-
new value
Attributes
- Returns
-
new JSON object
Updates value at given index.
Updates value at given index.
Value parameters
- index
-
array index
- value
-
JSON value
Attributes
- Returns
-
new JSON array
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
Gets array values.
Gets array values.
Attributes
Inherited methods
Converts value.
Gets value as JsonArray
.
Gets value as JsonArray
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonArray
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as JsonArray
.
Gets value as JsonArray
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonArray
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as BigDecimal
.
Gets value as BigDecimal
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as BigDecimal
.
Gets value as BigDecimal
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as BigInt
.
Gets value as BigInt
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ArithmeticException
if value cannot be represented exactly
java.lang.ClassCastExceptionif not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as BigInt
.
Gets value as BigInt
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ArithmeticException
if not represented exactly
java.lang.ClassCastExceptionif not JsonNumber
- Inherited from:
- JsonObject
Gets value as Boolean
.
Gets value as Boolean
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonBoolean
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as Boolean
.
Gets value as Boolean
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonBoolean
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as Double
.
Gets value as Double
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as Double
.
Gets value as Double
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as Float
.
Gets value as Float
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as Float
.
Gets value as Float
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonNumber
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as Int
.
Gets value as Int
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ArithmeticException
if not represented exactly
java.lang.ClassCastExceptionif not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as Int
.
Gets value as Int
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ArithmeticException
if not represented exactly
java.lang.ClassCastExceptionif not JsonNumber
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as Long
.
Gets value as Long
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ArithmeticException
if not represented exactly
java.lang.ClassCastExceptionif not JsonNumber
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as Long
.
Gets value as Long
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ArithmeticException
if not represented exactly
java.lang.ClassCastExceptionif not JsonNumber
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value as JsonObject
.
Gets value as JsonObject
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonObject
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as JsonObject
.
Gets value as JsonObject
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonObject
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Gets value or returns default.
Gets value or returns default.
Value parameters
- default
-
default value
- key
-
object key
Attributes
- Inherited from:
- JsonObject
Gets value as String
.
Gets value as String
.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonString
java.lang.IndexOutOfBoundsExceptionif index is out of bounds
- Inherited from:
- JsonArray
Gets value as String
.
Gets value as String
.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.ClassCastException
if not JsonString
java.util.NoSuchElementExceptionif key does not exist
- Inherited from:
- JsonObject
Tests for empty.
Tests for null.
Tests for null.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
- Inherited from:
- JsonArray
Tests for null.
Tests for null.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.util.NoSuchElementException
if key does not exist
- Inherited from:
- JsonObject
Tests for non-empty.
Reads value.
Reads value.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
java.lang.NullPointerExceptionif value is null
- Inherited from:
- JsonArray
Reads value.
Reads value.
Value parameters
- key
-
object key
Attributes
- Throws
-
java.lang.NullPointerException
if value is null
java.util.NoSuchElementExceptionif key does not exists
- Inherited from:
- JsonObject
Optionally reads value.
Optionally reads value.
Value parameters
- index
-
array index
Attributes
- Throws
-
java.lang.IndexOutOfBoundsException
if index is out of bounds
- Note
-
The value is not read if it is null.
- Inherited from:
- JsonArray
Optionally reads value.
Optionally reads value.
Value parameters
- key
-
object key
Attributes
- Note
-
The value is not read if it is null.
- Inherited from:
- JsonObject
Reads value or returns default value.
Reads value or returns default value.
Value parameters
- default
-
default value
- index
-
array index
Attributes
- Note
-
The value is not read if it is null.
- Inherited from:
- JsonArray
Reads value or returns default value.
Reads value or returns default value.
Value parameters
- default
-
default value
- key
-
object key
Attributes
- Note
-
The value is not read if it is null.
- Inherited from:
- JsonObject
Concrete fields
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.