Skip to main content

API Reference

Classes

Json

Immutable Json.

Methods

NameDescription
asBool
Convert Json element to boolean if possible.
asNum
Convert Json element to number if possible.
asStr
Convert Json element to string if possible.
get
Returns the value associated with the specified Json key.
getAt
Returns a specified element at a given index from Json Array.
has
Checks if a Json object has a given key.
tryAsBool
Convert Json element to boolean if possible.
tryAsNum
Convert Json element to number if possible.
tryAsStr
Convert Json element to string if possible.
tryGet
Optionally returns an specified element from the Json.
tryGetAt
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

NameDescription
deepCopy
Creates an immutable deep copy of the Json.
deepCopyMut
Creates a mutable deep copy of the Json.
delete
Deletes a key in a given Json.
entries
Returns the entries from the Json.
keys
Returns the keys from the Json.
parse
Parse a string into a Json.
stringify
Formats Json as string.
tryParse
Try to parse a string into a Json.
values
Returns the values from the Json.

deepCopy
Json.deepCopy(json: MutJson);

Creates an immutable deep copy of the Json.

jsonRequired

to copy.


deepCopyMut
Json.deepCopyMut(json: Json);

Creates a mutable deep copy of the Json.

jsonRequired

to copy.


delete
Json.delete(json: MutJson, key: str);

Deletes a key in a given Json.

jsonRequired

to delete key from.


keyRequired
  • Type: str

the key to delete.


entries
Json.entries(json: Json);

Returns the entries from the Json.

jsonRequired

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

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

map to get the values from.


JsonSchema

Struct Schema.

Initializers

new JsonSchema(schema: Json);
NameTypeDescription
schema
Json
No description.

schemaRequired

Methods

NameDescription
asStr
Retrieve the json schema as a string.
validate
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

the Json object to validate.


optionsOptional

MutJson

Mutable Json.

Methods

NameDescription
asBool
Convert Json element to boolean if possible.
asNum
Convert Json element to number if possible.
asStr
Convert Json element to string if possible.
delete
Removes the specified element from a map.
get
Returns the value associated with the specified Json key.
getAt
Returns a specified element at a given index from MutJson Array.
has
Checks if a Json object has a given key.
set
Adds or updates an element in MutJson with a specific key and value.
setAt
Set element in MutJson Array with a specific key and value.
tryAsBool
Convert Json element to boolean if possible.
tryAsNum
Convert Json element to number if possible.
tryAsStr
Convert Json element to string if possible.
tryGet
Optionally returns an specified element from the Json.
tryGetAt
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

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

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

NameTypeDescription
key
strThe entry key.
value
Json
The entry value.

keyRequired
key: str;
  • Type: str

The entry key.


valueRequired
value: Json;

The entry value.


JsonStringifyOptions

Options for stringify() method.

Initializer

let JsonStringifyOptions = JsonStringifyOptions{ ... };

Properties

NameTypeDescription
indent
numIndentation spaces number.

indentRequired
indent: num;
  • Type: num

Indentation spaces number.


JsonValidationOptions

Options for validating Json.

Initializer

let JsonValidationOptions = JsonValidationOptions{ ... };

Properties

NameTypeDescription
unsafe
boolUnsafe mode to skip validation (may lead to runtime errors).

unsafeOptional
unsafe: bool;
  • Type: bool

Unsafe mode to skip validation (may lead to runtime errors).