Module: json
Table of contents
Classes
Interfaces
Type Aliases
Functions
Type Aliases
JsonValue
Ƭ JsonValue: null
| number
| boolean
| string
| JsonObject
| JsonValue
[]
A JSON value
Defined in
Functions
fromJson
▸ fromJson(value
, options?
): Node
Encode the given JSON value into a JiK node
Parameters
Name | Type | Description |
---|---|---|
value | JsonValue | The JSON value to encode |
options? | FromJsonOptions | - |
Returns
Throws
If the given value contains cycles.
Defined in
parse
▸ parse(text
, reviver?
): JsonValue
Parse the given JiK text to its encoded JSON value
Parameters
Name | Type | Description |
---|---|---|
text | string | The JiK text to parse |
reviver? | JiKReviver <JsonValue > | - |
Returns
Throws
If the given text is not a valid JiK document
Defined in
▸ parse(text
, reviver
): unknown
Parse the given JiK text to its encoded JSON value
Parameters
Name | Type | Description |
---|---|---|
text | string | The JiK text to parse |
reviver | JiKReviver <unknown > | - |
Returns
unknown
Throws
If the given text is not a valid JiK document
Defined in
stringify
▸ stringify(value
, options?
): string
Stringify the given JSON value into JiK text
Parameters
Name | Type | Description |
---|---|---|
value | unknown | The JSON value to encode |
options? | StringifyOptions | Optional options |
Returns
string
Throws
If the given JSON value contains cycles.
Defined in
▸ stringify(value
, replacer?
, indentation?
): string
Stringify the given JSON value into JiK text
This function's signrature is explicitly kept similar to JSON.stringify
.
Parameters
Name | Type | Description |
---|---|---|
value | unknown | The JSON value to encode |
replacer? | (key : string | number , value : unknown , originalValue : unknown ) => unknown | - |
indentation? | string | number | The indentation to give each nested level of node, either the actual indentation string or the number of spaces |
Returns
string
Throws
If the given JSON value contains cycles.
Defined in
toJson
▸ toJson(nodeOrDocument
, options
): JsonObject
Extract the JSON value encoded into the given JiK node or document.
If passed a document, the document must contain a single node, which acts as the root of the JiK value.
Parameters
Name | Type | Description |
---|---|---|
nodeOrDocument | Node | Document | A valid JiK node or a document containing a single node which is a valid JiK node |
options | ToJsonOptions & ToJsonType <"object" > & { reviver? : undefined } | - |
Returns
See
https://github.com/kdl-org/kdl/blob/76d5dd542a9043257bc65476c0a70b94667052a7/JSON-IN-KDL.md
Throws
If the given node is not a valid JiK node or if the given document doesn't contain exactly one node
Defined in
▸ toJson(nodeOrDocument
, options
): JsonValue
[]
Extract the JSON value encoded into the given JiK node or document.
If passed a document, the document must contain a single node, which acts as the root of the JiK value.
Parameters
Name | Type | Description |
---|---|---|
nodeOrDocument | Node | Document | A valid JiK node or a document containing a single node which is a valid JiK node |
options | ToJsonOptions & ToJsonType <"array" > & { reviver? : undefined } | - |
Returns
See
https://github.com/kdl-org/kdl/blob/76d5dd542a9043257bc65476c0a70b94667052a7/JSON-IN-KDL.md
Throws
If the given node is not a valid JiK node or if the given document doesn't contain exactly one node
Defined in
▸ toJson(nodeOrDocument
, options?
): JsonValue
Extract the JSON value encoded into the given JiK node or document.
If passed a document, the document must contain a single node, which acts as the root of the JiK value.
Parameters
Name | Type | Description |
---|---|---|
nodeOrDocument | Node | Document | A valid JiK node or a document containing a single node which is a valid JiK node |
options? | ToJsonOptions & Partial <ToJsonType <string >> & Partial <ToJsonReviver <JsonValue >> | - |
Returns
See
https://github.com/kdl-org/kdl/blob/76d5dd542a9043257bc65476c0a70b94667052a7/JSON-IN-KDL.md
Throws
If the given node is not a valid JiK node or if the given document doesn't contain exactly one node
Defined in
▸ toJson(nodeOrDocument
, options?
): unknown
Extract the JSON value encoded into the given JiK node or document.
If passed a document, the document must contain a single node, which acts as the root of the JiK value.
Parameters
Name | Type | Description |
---|---|---|
nodeOrDocument | Node | Document | A valid JiK node or a document containing a single node which is a valid JiK node |
options? | ToJsonOptions & Partial <ToJsonType <string >> & Partial <ToJsonReviver <unknown >> | - |
Returns
unknown
See
https://github.com/kdl-org/kdl/blob/76d5dd542a9043257bc65476c0a70b94667052a7/JSON-IN-KDL.md
Throws
If the given node is not a valid JiK node or if the given document doesn't contain exactly one node