Json¶
Documentation for
std-library/nodes/components/json.ksp
Import¶
import "_IVLS/std-library/nodes/components/json.ksp"Node: JSON.Writer¶
Uses: Init, PCCB
API¶
Nodes¶
| Name | Description |
|---|---|
node JSON.Writer |
JSON writer node that manages serialization state and exposes an API for produci... |
Const Blocks¶
| Name | Description |
|---|---|
const command |
Command sentinel constants used to signal state transitions (push start marker o... |
const state |
State machine constants representing the current parser context of the JSON writ... |
const tokens |
JSON structural token constants for bracket and delimiter characters written to ... |
const type |
Value type constants used to distinguish integer, float, and string values in de... |
Functions¶
| Name | Description |
|---|---|
json.close() |
Closes the current JSON object or list scope, pops the state stack, and emits th... |
json.float_value(arg) |
Writes a float value at the current position in the JSON output. |
json.int_value(arg) |
Writes an integer value at the current position in the JSON output. |
json.key(name, length) |
Writes a JSON object key and transitions the state machine to KEY_AWAITING_VALUE. |
json.new() |
Starts a new JSON document by emitting the JSON_START sentinel and opening the r... |
json.open_list() |
Opens a new JSON list scope, pushes the LIST_AWAITING_VALUE_OR_CLOSE state, and ... |
json.open_object() |
Opens a new JSON object scope, pushes the OBJECT_AWAITING_KEY_OR_CLOSE state, an... |
json.str_value(arg) |
Writes a string value at the current position in the JSON output. |
json.test() |
Runs a self-contained JSON serialization test that writes a sample object with a... |
json.write(str) |
Writes a raw string fragment to the JSON output via message. |
JSON.Writer¶
node JSON.Writer¶
Callbacks: Init, PCCB
JSON writer node that manages serialization state and exposes an API for producing JSON output.
const state¶
State machine constants representing the current parser context of the JSON writer.
const type¶
Value type constants used to distinguish integer, float, and string values in deferred value dispatch.
const command¶
Command sentinel constants used to signal state transitions (push start marker or pop exit marker) to the state property setter.
const tokens¶
JSON structural token constants for bracket and delimiter characters written to the output stream.
json.test()¶
Runs a self-contained JSON serialization test that writes a sample object with a nested list to the message log.
json.write(str)¶
Writes a raw string fragment to the JSON output via message.
| Parameter | Type | Description |
|---|---|---|
str |
string | The string content to emit to the output stream |
json.new()¶
Starts a new JSON document by emitting the JSON_START sentinel and opening the root object.
json.key(name, length)¶
Writes a JSON object key and transitions the state machine to KEY_AWAITING_VALUE.
| Parameter | Type | Description |
|---|---|---|
name |
string | The key string to write into the JSON output |
length |
integer | The byte length of the key string |
json.int_value(arg)¶
Writes an integer value at the current position in the JSON output.
| Parameter | Type | Description |
|---|---|---|
arg |
integer | The integer value to write as the current JSON value |
json.str_value(arg)¶
Writes a string value at the current position in the JSON output.
| Parameter | Type | Description |
|---|---|---|
arg |
string | The string value to write as the current JSON value |
json.float_value(arg)¶
Writes a float value at the current position in the JSON output.
| Parameter | Type | Description |
|---|---|---|
arg |
real | The floating-point value to write as the current JSON value |
json.open_object()¶
Opens a new JSON object scope, pushes the OBJECT_AWAITING_KEY_OR_CLOSE state, and emits the opening brace.
json.open_list()¶
Opens a new JSON list scope, pushes the LIST_AWAITING_VALUE_OR_CLOSE state, and emits the opening bracket.
json.close()¶
Closes the current JSON object or list scope, pops the state stack, and emits the appropriate closing bracket.
Example¶
// TODO: Add usage example