JsonValue
Defines JSON value.
Value members
Abstract methods
Adds or updates field.
Adds or updates field.
- Returns:
new JSON object
Concatenates JSON array.
Concatenates JSON array.
- Returns:
new JSON array
Concatenates JSON object.
Concatenates JSON object.
- Returns:
new JSON object
Prepends value.
Prepends value.
- Returns:
new JSON array
Removes field.
Removes field.
- Value parameters:
- name
field name
- Returns:
new JSON object
Appends value.
Appends value.
- Returns:
new JSON array
Gets optional value.
Gets optional value.
- Value parameters:
- name
field name
Selects first value in array.
Selects first value in array.
- Throws:
- NoSuchElementException
if array is empty
Optionally selects first value in array.
Optionally selects first value in array.
Selects all values in array excluding last.
Selects all values in array excluding last.
- Throws:
- UnsupportedOperationException
if array is empty
Selects last value in array.
Selects last value in array.
- Throws:
- NoSuchElementException
if array is empty
Optionally selects last value in array.
Optionally selects last value in array.
Selects slice of array.
Selects slice of array.
- Value parameters:
- from
lowest index to include
- until
lowest index to exclude
- Returns:
slice of JSON array containing elements whose indexes are greater than or equal to
from
and less thanuntil
Selects all values in array excluding first.
Selects all values in array excluding first.
- Throws:
- UnsupportedOperationException
if array is empty
Updates value at given index.
Updates value at given index.
- Returns:
new JSON array
Concrete methods
Gets value in JSON object.
Gets value in JSON object.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonObject
Gets value in JSON array.
Gets value in JSON array.
- Value parameters:
- index
array index
- Throws:
- ClassCastException
if not JsonArray
Collects values with given field name while traversing nested objects and arrays.
Collects values with given field name 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:
- name
field name
Gets BigDecimal at given index.
Gets BigDecimal at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets BigDecimal.
Gets BigDecimal.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets BigInt at given index.
Gets BigInt at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets BigInt.
Gets BigInt.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets Boolean at given index.
Gets Boolean at given index.
- Throws:
- ClassCastException
if not JsonBoolean
Gets Boolean.
Gets Boolean.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonBoolean
Gets Byte at given index.
Gets Byte at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Byte.
Gets Byte.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets Double at given index.
Gets Double at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Double.
Gets Double.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets Float at given index.
Gets Float at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Float.
Gets Float.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets Int at given index.
Gets Int at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Int.
Gets Int.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets JSON array at given index.
Gets JSON array at given index.
- Throws:
- ClassCastException
if not JsonArray
Gets JSON array.
Gets JSON array.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonArray
Gets JSON boolean at given index.
Gets JSON boolean at given index.
- Throws:
- ClassCastException
if not JsonBoolean
Gets JSON boolean.
Gets JSON boolean.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonBoolean
Gets JSON null at given index.
Gets JSON null at given index.
- Throws:
- ClassCastException
if not JsonNull
Gets JSON null.
Gets JSON null.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNull
Gets JSON number at given index.
Gets JSON number at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets JSON number.
Gets JSON number.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets JSON object at given index.
Gets JSON object at given index.
- Throws:
- ClassCastException
if not JsonObject
Gets JSON object.
Gets JSON object.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonObject
Gets JSON string at given index.
Gets JSON string at given index.
- Throws:
- ClassCastException
if not JsonString
Gets JSON string.
Gets JSON string.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonString
Gets Long at given index.
Gets Long at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Long.
Gets Long.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets converted value or returns default if not present.
Gets converted value or returns default if not present.
- Value parameters:
- default
default value
- name
field name
Gets Short at given index.
Gets Short at given index.
- Throws:
- ClassCastException
if not JsonNumber
Gets Short.
Gets Short.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNumber
Gets String at given index.
Gets String at given index.
- Throws:
- ClassCastException
if not JsonString
Gets String.
Gets String.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonString
Tests for null at given index.
Tests for null at given index.
Tests for null.
Tests for null.
- Value parameters:
- name
field name
- Throws:
- ClassCastException
if not JsonNull
Maps optional value excluding null.
Maps optional value excluding null.
- Value parameters:
- name
field name
Inherited methods
Tests for emptiness.
Tests for emptiness.
- Inherited from:
- JsonStructure
Tests for emptiness.
Tests for emptiness.
- Inherited from:
- JsonStructure