Skip to main content

Module json

Module json 

Source
Expand description

JSON construction, serialization, and manipulation nodes.

JSON is a first-class Value type in the GK. Nodes can produce and consume Value::Json(std::sync::Arc::new(serde_json::Value)) directly, avoiding serialization/deserialization round-trips when passing structured data between nodes or to adapters that consume JSON natively.

Objects are built compositionally: json_with(key, value) produces a single-pair partial Json, and the variadic json_object(parts...) merges them. Workload syntax:

record := json_object(
    json_with("name", name_wire),
    json_with("age", age_wire),
)

Structs§

ArrayAt
Return the element at a given index from a bracket-encoded array.
ArrayLen
Return the number of elements in a bracket-encoded array string.
BodyColumnI32
body_column_i32(body, "name") — extract the named column from every row of a JSON result body, parse each as i32, and return the values as a VecI32 wire.
EscapeJson
Escape a string for safe embedding in a JSON string value.
JsonArray
Build a JSON array from N inputs.
JsonField
Extract a field from a JSON object by key.
JsonMerge
Merge two JSON objects into one (shallow merge, right wins).
JsonObject
Merge N partial Json Objects into a single Json Object.
JsonText
Flatten a JSON tree into a single newline-separated text by concatenating every leaf value’s textual form.
JsonToStr
Serialize a JSON value to a compact string.
JsonToStrPretty
Serialize a JSON value to a pretty-printed string.
JsonWith
Build a single-pair partial JSON object: { key: value }.
NormalizeVector
L2-normalize a bracket-encoded float vector string [1.0,2.0,3.0].
RandomVector
Generate a deterministic f64 vector as a bracket-encoded JSON array string.
StrToJson
Parse a JSON string into a JSON value.
ToJson
Wrap a single value as a JSON value.