JsonObject

grapple.json.JsonObject
See theJsonObject companion object
trait JsonObject extends JsonStructure

Represents JSON object.

Attributes

See also
Companion
object
Graph
Supertypes
trait JsonValue
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def ++(other: JsonObject): JsonObject

Concatenates JSON object.

Concatenates JSON object.

Attributes

Returns

new JSON object

def apply(key: String): JsonValue

Gets value.

Gets value.

Value parameters

key

object key

Attributes

Throws
java.util.NoSuchElementException

if key does not exist

def fields: Map[String, JsonValue]

Gets object fields.

Gets object fields.

Attributes

def get(key: String): Option[JsonValue]

Optionally gets value.

Optionally gets value.

Value parameters

key

object key

Attributes

Throws
java.util.NoSuchElementException

if key does not exist

def keys: Set[String]

Gets object keys.

Gets object keys.

Attributes

def removed(key: String): JsonObject

Removes field.

Removes field.

Value parameters

key

object key

Attributes

Returns

new JSON object

def updated(key: String, value: JsonValue): JsonObject

Adds or updates field.

Adds or updates field.

Value parameters

key

object key

value

new value

Attributes

Returns

new JSON object

Concrete methods

def getArray(key: String): JsonArray

Gets value as JsonArray.

Gets value as JsonArray.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonArray

java.util.NoSuchElementException

if key does not exist

def getBigDecimal(key: String): BigDecimal

Gets value as BigDecimal.

Gets value as BigDecimal.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonNumber

java.util.NoSuchElementException

if key does not exist

def getBigInt(key: String): BigInt

Gets value as BigInt.

Gets value as BigInt.

Value parameters

key

object key

Attributes

Throws
java.lang.ArithmeticException

if not represented exactly

java.lang.ClassCastException

if not JsonNumber

def getBoolean(key: String): Boolean

Gets value as Boolean.

Gets value as Boolean.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonBoolean

java.util.NoSuchElementException

if key does not exist

def getDouble(key: String): Double

Gets value as Double.

Gets value as Double.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonNumber

java.util.NoSuchElementException

if key does not exist

def getFloat(key: String): Float

Gets value as Float.

Gets value as Float.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonNumber

java.util.NoSuchElementException

if key does not exist

def getInt(key: String): Int

Gets value as Int.

Gets value as Int.

Value parameters

key

object key

Attributes

Throws
java.lang.ArithmeticException

if not represented exactly

java.lang.ClassCastException

if not JsonNumber

java.util.NoSuchElementException

if key does not exist

def getLong(key: String): Long

Gets value as Long.

Gets value as Long.

Value parameters

key

object key

Attributes

Throws
java.lang.ArithmeticException

if not represented exactly

java.lang.ClassCastException

if not JsonNumber

java.util.NoSuchElementException

if key does not exist

def getObject(key: String): JsonObject

Gets value as JsonObject.

Gets value as JsonObject.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonObject

java.util.NoSuchElementException

if key does not exist

def getOrElse(key: String, default: => JsonValue): JsonValue

Gets value or returns default.

Gets value or returns default.

Value parameters

default

default value

key

object key

Attributes

def getString(key: String): String

Gets value as String.

Gets value as String.

Value parameters

key

object key

Attributes

Throws
java.lang.ClassCastException

if not JsonString

java.util.NoSuchElementException

if key does not exist

def isNull(key: String): Boolean

Tests for null.

Tests for null.

Value parameters

key

object key

Attributes

Throws
java.util.NoSuchElementException

if key does not exist

def read[T](key: String)(using JsonInput[T]): T

Reads value.

Reads value.

Value parameters

key

object key

Attributes

Throws
java.lang.NullPointerException

if value is null

java.util.NoSuchElementException

if key does not exists

def readOption[T](key: String)(using JsonInput[T]): Option[T]

Optionally reads value.

Optionally reads value.

Value parameters

key

object key

Attributes

Note

The value is not read if it is null.

def readOrElse[T](key: String, default: => T)(using JsonInput[T]): T

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 methods

final def as[T](using input: JsonInput[T]): T

Converts value.

Converts value.

Value parameters

input

converter

Attributes

Inherited from:
JsonValue
def isEmpty: Boolean

Tests for empty.

Tests for empty.

Attributes

Inherited from:
JsonStructure
def nonEmpty: Boolean

Tests for non-empty.

Tests for non-empty.

Attributes

Inherited from:
JsonStructure
def size: Int

Gets size.

Gets size.

Attributes

Inherited from:
JsonStructure