API Reference
Classes
Json
Immutable Json.
Methods
| Name | Description |
|---|---|
| Convert Json element to boolean if possible. |
| Convert Json element to number if possible. |
| Convert Json element to string if possible. |
| Returns the value associated with the specified Json key. |
| Returns a specified element at a given index from Json Array. |
| Checks if a Json object has a given key. |
| Convert Json element to boolean if possible. |
| Convert Json element to number if possible. |
| Convert Json element to string if possible. |
| Optionally returns an specified element from the Json. |
| Optionally returns a specified element at a given index from Json Array. |
asBool
asBool(): bool
Convert Json element to boolean if possible.
asNum
asNum(): num
Convert Json element to number if possible.
asStr
asStr(): str
Convert Json element to string if possible.
get
get(key: str): Json
Returns the value associated with the specified Json key.
keyRequired
- Type: str
The key of the Json property.
getAt
getAt(index: num): Json
Returns a specified element at a given index from Json Array.
indexRequired
- Type: num
The index of the element in the Json Array to return.
has
has(key: str): bool
Checks if a Json object has a given key.
keyRequired
- Type: str
The key to check.
tryAsBool
tryAsBool(): bool?
Convert Json element to boolean if possible.
tryAsNum
tryAsNum(): num?
Convert Json element to number if possible.
tryAsStr
tryAsStr(): str?
Convert Json element to string if possible.
tryGet
tryGet(key: str): Json?
Optionally returns an specified element from the Json.
keyRequired
- Type: str
The key of the element to return.
tryGetAt
tryGetAt(index: num): Json?
Optionally returns a specified element at a given index from Json Array.
indexRequired
- Type: num
The index of the element in the Json Array to return.
Static Functions
| Name | Description |
|---|---|
| Creates an immutable deep copy of the Json. |
| Creates a mutable deep copy of the Json. |
| Deletes a key in a given Json. |
| Returns the entries from the Json. |
| Returns the keys from the Json. |
| Parse a string into a Json. |
| Formats Json as string. |
| Try to parse a string into a Json. |
| Returns the values from the Json. |
deepCopy
Json.deepCopy(json: MutJson);
Creates an immutable deep copy of the Json.
jsonRequired
- Type: MutJson
to copy.
deepCopyMut
Json.deepCopyMut(json: Json);
Creates a mutable deep copy of the Json.
jsonRequired
- Type: Json
to copy.
delete
Json.delete(json: MutJson, key: str);
Deletes a key in a given Json.
jsonRequired
- Type: MutJson
to delete key from.
keyRequired
- Type: str
the key to delete.
entries
Json.entries(json: Json);
Returns the entries from the Json.
jsonRequired
- Type: Json
map to get the entries from.
keys
Json.keys(json: any);
Returns the keys from the Json.
jsonRequired
- Type: any
map to get the keys from.
parse
Json.parse(str: str);
Parse a string into a Json.
strRequired
- Type: str
to parse as Json.
stringify
Json.stringify(json: any, options?: JsonStringifyOptions);
Formats Json as string.
jsonRequired
- Type: any
to format as string.
optionsOptional
- Type: JsonStringifyOptions
tryParse
Json.tryParse(str?: str);
Try to parse a string into a Json.
strOptional
- Type: str
to parse as Json.
values
Json.values(json: Json);
Returns the values from the Json.
jsonRequired
- Type: Json
map to get the values from.
JsonSchema
Struct Schema.
Initializers
new JsonSchema(schema: Json);
| Name | Type | Description |
|---|---|---|
| | No description. |
schemaRequired
- Type: Json
Methods
| Name | Description |
|---|---|
| Retrieve the json schema as a string. |
| Attempt to validate a json object against the schema. |
asStr
asStr(): str
Retrieve the json schema as a string.
validate
validate(obj: Json, options?: JsonValidationOptions): void
Attempt to validate a json object against the schema.
objRequired
- Type: Json
the Json object to validate.
optionsOptional
- Type: JsonValidationOptions
MutJson
Mutable Json.
Methods
| Name | Description |
|---|---|
| Convert Json element to boolean if possible. |
| Convert Json element to number if possible. |
| Convert Json element to string if possible. |
| Removes the specified element from a map. |
| Returns the value associated with the specified Json key. |
| Returns a specified element at a given index from MutJson Array. |
| Checks if a Json object has a given key. |
| Adds or updates an element in MutJson with a specific key and value. |
| Set element in MutJson Array with a specific key and value. |
| Convert Json element to boolean if possible. |
| Convert Json element to number if possible. |
| Convert Json element to string if possible. |
| Optionally returns an specified element from the Json. |
| Optionally returns a specified element at a given index from Json Array. |
asBool
asBool(): bool
Convert Json element to boolean if possible.
asNum
asNum(): num
Convert Json element to number if possible.
asStr
asStr(): str
Convert Json element to string if possible.
delete
delete(key: str): bool
Removes the specified element from a map.
keyRequired
- Type: str
The key.
get
get(key: str): MutJson
Returns the value associated with the specified Json key.
keyRequired
- Type: str
The key of the Json property.
getAt
getAt(index: num): MutJson
Returns a specified element at a given index from MutJson Array.
indexRequired
- Type: num
The index of the element in the MutJson Array to return.
has
has(key: str): bool
Checks if a Json object has a given key.
keyRequired
- Type: str
The key to check.
set
set(key: str, value: MutJson): void
Adds or updates an element in MutJson with a specific key and value.
keyRequired
- Type: str
The key of the element to add.
valueRequired
- Type: MutJson
The value of the element to add.
setAt
setAt(index: num, value: MutJson): void
Set element in MutJson Array with a specific key and value.
indexRequired
- Type: num
valueRequired
- Type: MutJson
The value of the element to set.
tryAsBool
tryAsBool(): bool?
Convert Json element to boolean if possible.
tryAsNum
tryAsNum(): num?
Convert Json element to number if possible.
tryAsStr
tryAsStr(): str?
Convert Json element to string if possible.
tryGet
tryGet(key: str): MutJson?
Optionally returns an specified element from the Json.
keyRequired
- Type: str
The key of the element to return.
tryGetAt
tryGetAt(index: num): MutJson?
Optionally returns a specified element at a given index from Json Array.
indexRequired
- Type: num
The index of the element in the Json Array to return.
Structs
JsonEntry
Json entry representation.
Initializer
let JsonEntry = JsonEntry{ ... };
Properties
| Name | Type | Description |
|---|---|---|
| str | The entry key. |
| | The entry value. |
keyRequired
key: str;
- Type: str
The entry key.
valueRequired
value: Json;
- Type: Json
The entry value.
JsonStringifyOptions
Options for stringify() method.
Initializer
let JsonStringifyOptions = JsonStringifyOptions{ ... };
Properties
| Name | Type | Description |
|---|---|---|
| num | Indentation spaces number. |
indentRequired
indent: num;
- Type: num
Indentation spaces number.
JsonValidationOptions
Options for validating Json.
Initializer
let JsonValidationOptions = JsonValidationOptions{ ... };
Properties
| Name | Type | Description |
|---|---|---|
| bool | Unsafe mode to skip validation (may lead to runtime errors). |
unsafeOptional
unsafe: bool;
- Type: bool
Unsafe mode to skip validation (may lead to runtime errors).