JsonObject
Represents JSON object.
| To parse string into JsonObject use JsonParse. |
Instance attributes
Attribute values can be accessed in the same way as instance attribute (obj.key, null if the key does not exist). Assigning to an attribute (obj.key = value) works the same as set().
Instance methods
- get(key) ⇒ ?
-
Returns attribute value by the key. Value type depends on the type used in JSON.
Table 1. Parameters key
String
Attribute key
ReturnAttribute value, or
nullif the key does not exist. Nested JSON objects and arrays are returned asJsonObjectand JsonArray.
- keys(): Array
-
Returns attribute array
ReturnAttribute array
- serialize(): String
-
Returns string with serialized JSON
ReturnString with JSON
- set(key, value): void
-
Sets attribute referenced by key to the given value. Accepts nested JsonArray and
JsonObjectvalues as well as other values converted to JSON. A nestedJsonArrayorJsonObjectis stored by reference, not copied: changing it afterwards also changes this object. The same applies to attribute assignment (obj.key = value) and to nested values returned byget.Table 2. Parameters key
String
Attribute key
value
any
Attribute new value
- setBoolean(key, value): void
-
Sets a boolean value at the specified key. The value is converted to boolean.
Table 3. Parameters key
String
Attribute key
value
any
Value to convert to boolean
- setNull(key): void
-
Sets a JSON null value at the specified key.
Table 4. Parameters key
String
Attribute key
- setString(key, value): void
-
Sets a string value at the specified key. The value is converted to string.
Table 5. Parameters key
String
Attribute key
value
any
Value to convert to string