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.
key
Required
- Type: str
The key of the Json property.
getAt
getAt(index: num): Json
Returns a specified element at a given index from Json Array.
index
Required
- 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.
key
Required
- 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.
key
Required
- 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.
index
Required
- 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.
json
Required
- Type: MutJson
to copy.
deepCopyMut
Json.deepCopyMut(json: Json);
Creates a mutable deep copy of the Json.
json
Required
- Type: Json
to copy.
delete
Json.delete(json: MutJson, key: str);
Deletes a key in a given Json.
json
Required
- Type: MutJson
to delete key from.
key
Required
- Type: str
the key to delete.
entries
Json.entries(json: Json);
Returns the entries from the Json.
json
Required
- Type: Json
map to get the entries from.
keys
Json.keys(json: any);
Returns the keys from the Json.
json
Required
- Type: any
map to get the keys from.
parse
Json.parse(str: str);
Parse a string into a Json.
str
Required
- Type: str
to parse as Json.
stringify
Json.stringify(json: any, options?: JsonStringifyOptions);
Formats Json as string.
json
Required
- Type: any
to format as string.
options
Optional
- Type: JsonStringifyOptions
tryParse
Json.tryParse(str?: str);
Try to parse a string into a Json.
str
Optional
- Type: str
to parse as Json.
values
Json.values(json: Json);
Returns the values from the Json.
json
Required
- Type: Json
map to get the values from.
JsonSchema
Struct Schema.
Initializers
new JsonSchema(schema: Json);
Name | Type | Description |
---|---|---|
|
| No description. |
schema
Required
- 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.
obj
Required
- Type: Json
the Json object to validate.
options
Optional
- 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.
key
Required
- Type: str
The key.
get
get(key: str): MutJson
Returns the value associated with the specified Json key.
key
Required
- Type: str
The key of the Json property.
getAt
getAt(index: num): MutJson
Returns a specified element at a given index from MutJson Array.
index
Required
- 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.
key
Required
- 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.
key
Required
- Type: str
The key of the element to add.
value
Required
- 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.
index
Required
- Type: num
value
Required
- 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.
key
Required
- 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.
index
Required
- 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. |
key
Required
key: str;
- Type: str
The entry key.
value
Required
value: Json;
- Type: Json
The entry value.
JsonStringifyOptions
Options for stringify() method.
Initializer
let JsonStringifyOptions = JsonStringifyOptions{ ... };
Properties
Name | Type | Description |
---|---|---|
| num | Indentation spaces number. |
indent
Required
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). |
unsafe
Optional
unsafe: bool;
- Type: bool
Unsafe mode to skip validation (may lead to runtime errors).