Targets · JSON · Object format
Object format
Every canonical node in the object form, keyword by keyword — the exact JSON that the Structure types serialise to. Field types and shared nodes link back to their definition on the Structure page.
Contents
JSON is the canonical command form every module is stored in — the interchange the other targets render from, not a language you run. These pages describe that form.
- Introduction — what the JSON form is, and how to read the rest of this section.
- Capabilities — which high-level features are possible — deferred to whichever target this JSON renders to.
- Example — a full program using every keyword, in the canonical JSON form.
- Naming considerations — how Program's dotted names are stored, verbatim and un-munged.
- Object format — every node in the self-describing object form, keyword by keyword.
- Array format — every node in the compact tagged-array form, keyword by keyword.
- Project setup — there is no build; how a module file is stored, read and rendered onward.
- Reserved words — why the canonical form has none, and never escapes a name.
Conventions
How each shape maps into object form, node by node:
| Case | Object based | Array based |
|---|---|---|
| A keyword node | an object under its keyword, { "MODULE": { … } } | a tagged array, ["MODULE", …] |
| A union value (one option chosen from several) | a single-key object { "<option>": value } | a two-element array ["<option>", value] |
| An optional value that is absent | the field is null | the position is null |
| An optional value at the end of an array | the key is omitted | the trailing position is dropped entirely |
| A union option carrying no data (e.g. a direction) | the bare option name, "binding" | the bare option name, "binding" |
| An identifier (a declared name) | the bare name string, "Greet" | the bare name string, "Greet" |
ROOT
{ "ROOT": {
"modules": [
{ "MODULE": { "name": "App", "modules": [], "types": [], "functions": [], "constants": [], "natives": [], "nativeTypes": [] } }
],
"natives": [
{ "NATIVE": { "platform": "js", "code": "globalThis.__boot = true;" } }
],
"run": [
{ "CALL": { "functionName": "App.Main", "typeArguments": [], "arguments": [] } }
]
} }
| Field | Type | Description |
|---|---|---|
modules | array of MODULE | The top-level modules. |
natives | array of NATIVE | Per-target native setup blocks that run as the program starts. |
run | array of BodyCommand | The run body: the program's entry point, where a bare CALL may appear. |
MODULE
{ "MODULE": {
"name": "App",
"modules": [],
"types": [
{ "TYPE": { "name": "Profile", "genericTypes": [], "fields": [
{ "FIELD": { "name": "name", "type": "Text" } }
], "options": [], "natives": [] } }
],
"functions": [
{ "FUNCTION": { "name": "Greet", "genericTypes": [], "inputs": [
{ "INPUT": { "name": "name", "type": "Text", "direction": "forward" } }
], "holes": [], "return": { "name": "__return", "type": "Text", "optionalDirection": null },
"body": { "implementations": [
{ "NATIVE": { "platform": "js", "code": "return 'Hi ' + name;" } }
] } } }
],
"constants": [
{ "LET": { "name": "MaxRetries", "type": "Maths.Integer", "value": { "constant": { "literal": { "integer": 3 } } } } }
],
"natives": [],
"nativeTypes": []
} }
| Field | Type | Description |
|---|---|---|
name | Identifier | The module's name. |
modules | array of MODULE | Nested modules. |
types | array of TYPE | The module's types. |
functions | array of FUNCTION | Derived functions. |
constants | array of LET | Module-level constants, each a LET binding a constant expression. |
natives | array of FUNCTION | Native functions (body is implementations). |
nativeTypes | array of native type | Native type declarations. |
FUNCTION
{ "FUNCTION": {
"name": "Welcome",
"genericTypes": [],
"inputs": [
{ "INPUT": { "name": "profile", "type": "App.Profile", "direction": "binding" } }
],
"holes": [
{ "HOLE": { "name": "row", "type": "Text", "inputs": [
{ "INPUT": { "name": "line", "type": "Text", "direction": "forward" } }
] } }
],
"return": { "name": "__return", "type": "Text", "optionalDirection": null },
"body": { "body": [
{ "LET": { "name": "label", "type": "Text", "value": { "reference": "profile" } } }
] }
} }
| Field | Type | Description |
|---|---|---|
name | Identifier | The function's name. |
genericTypes | array of Reference | Names of the generic type parameters, if any. |
inputs | array of INPUT | The typed parameters. |
holes | array of HOLE | The callback parameters the caller fills. Empty for most functions. |
return | Return or null | The return name and type, or null for no return. |
body | FunctionBody union | { "body": […] } for a derived function, or { "implementations": […] } for a native one. |
INPUT
{ "INPUT": { "name": "profile", "type": "App.Profile", "direction": "binding" } }
| Field | Type | Description |
|---|---|---|
name | Identifier | The parameter name. |
type | Text | The parameter's type, as a name. |
direction | Direction | One of "forward", "binding", "reverse". |
default | ConstantExpression, optional | The default value; the key is absent when there is none. |
HOLE
{ "HOLE": { "name": "row", "type": "Text", "inputs": [
{ "INPUT": { "name": "line", "type": "Text", "direction": "forward" } }
] } }
| Field | Type | Description |
|---|---|---|
name | Identifier | The hole's name. |
type | Text or null | The block's return type, or null if it returns nothing. |
inputs | array of INPUT | The values passed into the block. |
NATIVE
{ "NATIVE": { "platform": "js", "code": "return 'Hi ' + name;" } }
| Field | Type | Description |
|---|---|---|
platform | Text | The target name: dart, swift, js, nodejs, ts, go, rust, zig, glsl or php. |
code | Text | The host source for that target — a function body, or a type alias for a native type. |
TYPE
{ "TYPE": {
"name": "Status",
"genericTypes": [],
"fields": [],
"options": [
{ "OPTION": { "name": "active", "type": "App.Profile" } },
{ "OPTION": { "name": "pending", "type": "Text" } }
],
"natives": []
} }
| Field | Type | Description |
|---|---|---|
name | Identifier | The type's name. |
genericTypes | array of Reference | Generic type parameter names, if any. |
fields | array of FIELD | The record's fields; empty for a union or native type. |
options | array of OPTION | The union's options; empty for a record or native type. |
natives | array of NATIVE | Per-target native implementations; empty for a record or union. |
FIELD
{ "FIELD": { "name": "age", "type": "Maths.Integer" } }
| Field | Type | Description |
|---|---|---|
name | Identifier | The field name. |
type | Text | The field's type, as a name. |
default | ConstantExpression, optional | The field's default; the key is absent when there is none. |
OPTION
{ "OPTION": { "name": "active", "type": "App.Profile" } }
| Field | Type | Description |
|---|---|---|
name | Identifier | The option name; reads back as an Optional of its type. |
type | Text | The option's payload type. |
LET
{ "LET": {
"name": "label",
"type": "Text",
"value": { "call": {
"functionName": "Maths.Integer.ToString",
"typeArguments": [],
"arguments": [ { "reference": "count" } ]
} }
} }
| Field | Type | Description |
|---|---|---|
name | Identifier | The bound name. |
type | Text | The value's type. |
value | AssignmentValue union | { "reference": name } or { "call": FunctionCall }. |
STATE
{ "STATE": { "name": "count", "type": "Maths.Integer", "initial": { "constant": { "literal": { "integer": 0 } } }, "lockable": false } }
| Field | Type | Description |
|---|---|---|
name | Identifier | The cell's name. |
type | Text | The cell's type. |
initial | AssignmentValue or null | The starting value (reference, call or constant), or null for a locked-empty cell. |
lockable | Logic.Maybe | true for a LOCKED cell, otherwise false. |
REVERSE
{ "REVERSE": {
"name": "submit",
"type": "App.Profile",
"body": [
{ "LET": { "name": "response", "type": "Network.Web.Response",
"value": { "call": {
"functionName": "Network.Web.Client.Post", "typeArguments": [],
"arguments": [ { "reference": "profile" } ] } } } }
],
"setters": [
{ "SET": { "outerSettable": "saved", "innerValue": "response" } }
]
} }
| Field | Type | Description |
|---|---|---|
name | Identifier | The reverse's name. |
type | Text | The type being written back. |
body | array of BodyCommand | The work done before the write. |
setters | array of SET | The write-backs into outer state. |
SET
{ "SET": { "outerSettable": "saved", "innerValue": "response" } }
| Field | Type | Description |
|---|---|---|
outerSettable | Text | The outer state cell to write into. |
innerValue | Text | The name of the inner value to write. |
WITH
{ "WITH": {
"module": "Network.Web.Client",
"replacement": "Network.Web.Mock",
"body": [
{ "LET": { "name": "response", "type": "Network.Web.Response",
"value": { "call": {
"functionName": "Network.Web.Client.Post", "typeArguments": [],
"arguments": [ { "reference": "profile" } ] } } } }
]
} }
| Field | Type | Description |
|---|---|---|
module | Text | The module whose implementation is swapped. |
replacement | Text | The module swapped in for the block. |
body | array of BodyCommand | The commands the swap applies over. |