Targets · JSON · Array format

Array format

Every canonical node in the array 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.

Conventions

How each shape maps into array form, node by node:

CaseObject basedArray based
A keyword nodean 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 absentthe field is nullthe position is null
An optional value at the end of an arraythe key is omittedthe 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",
  [ ["MODULE", "App", [], [], [], [], [], []] ],
  [ ["NATIVE", "js", "globalThis.__boot = true;"] ],
  [ ["CALL", "App.Main", [], []] ]
]
ROOT keyword JSON array definition
PositionTypeDescription
0 · tag"ROOT"Constant tag.
1 · modulesarray of MODULEThe top-level modules.
2 · nativesarray of NATIVETop-level native setup blocks.
3 · runarray of BodyCommandThe run body.

MODULE

["MODULE", "App", [], [
  ["TYPE", "Profile", [], [
    ["FIELD", "name", "Text"]
  ], [], []]
], [
  ["FUNCTION", "Greet", [], [
    ["INPUT", "name", "Text", "forward"]
  ], [], ["__return", "Text", null], ["implementations", [
    ["NATIVE", "js", "return 'Hi ' + name;"]
  ]]]
], [
  ["LET", "MaxRetries", "Maths.Integer", ["constant", ["literal", ["integer", 3]]]]
], [], []]
MODULE keyword JSON array definition
PositionTypeDescription
0 · tag"MODULE"Constant tag.
1 · nameIdentifierThe module's name.
2 · modulesarray of MODULENested modules.
3 · typesarray of TYPEThe module's types.
4 · functionsarray of FUNCTIONDerived functions.
5 · constantsarray of LETModule-level constants.
6 · nativesarray of FUNCTIONNative functions.
7 · nativeTypesarray of native typeNative type declarations.

FUNCTION

["FUNCTION", "Welcome", [],
  [["INPUT", "profile", "App.Profile", "binding"]],
  [["HOLE", "row", "Text", [["INPUT", "line", "Text", "forward"]]]],
  ["__return", "Text", null],
  ["body", [
    ["LET", "label", "Text", ["reference", "profile"]]
  ]]
]
FUNCTION keyword JSON array definition
PositionTypeDescription
0 · tag"FUNCTION"Constant tag.
1 · nameIdentifierThe function's name.
2 · genericTypesarray of ReferenceGeneric type parameter names.
3 · inputsarray of INPUTThe typed parameters.
4 · holesarray of HOLEThe callback parameters.
5 · returnReturn or nullThe return, or null.
6 · bodyFunctionBody union["body", […]] or ["implementations", […]].

INPUT

["INPUT", "profile", "App.Profile", "binding"]
INPUT keyword JSON array definition
PositionTypeDescription
0 · tag"INPUT"Constant tag.
1 · nameIdentifierThe parameter name.
2 · typeTextThe parameter's type.
3 · directionDirectionForward, binding or reverse.
4 · optionalDefaultConstantExpression, trailingThe default; omitted from the end when there is none.

HOLE

["HOLE", "row", "Text", [
  ["INPUT", "line", "Text", "forward"]
]]
HOLE keyword JSON array definition
PositionTypeDescription
0 · tag"HOLE"Constant tag.
1 · nameIdentifierThe hole's name.
2 · typeText or nullThe block's return type, or null.
3 · inputsarray of INPUTThe values passed into the block.

NATIVE

["NATIVE", "js", "return 'Hi ' + name;"]
NATIVE keyword JSON array definition
PositionTypeDescription
0 · tag"NATIVE"Constant tag.
1 · platformTextThe target name.
2 · codeTextThe host source for that target.

TYPE

["TYPE", "Status", [], [], [
  ["OPTION", "active", "App.Profile"],
  ["OPTION", "pending", "Text"]
], []]
TYPE keyword JSON array definition
PositionTypeDescription
0 · tag"TYPE"Constant tag.
1 · nameIdentifierThe type's name.
2 · genericTypesarray of ReferenceGeneric type parameter names.
3 · fieldsarray of FIELDThe record's fields.
4 · optionsarray of OPTIONThe union's options.
5 · nativesarray of NATIVEPer-target native implementations.

FIELD

["FIELD", "age", "Maths.Integer"]
FIELD keyword JSON array definition
PositionTypeDescription
0 · tag"FIELD"Constant tag.
1 · nameIdentifierThe field name.
2 · typeTextThe field's type.
3 · optionalDefaultConstantExpression, trailingThe default; omitted from the end when there is none.

OPTION

["OPTION", "active", "App.Profile"]
OPTION keyword JSON array definition
PositionTypeDescription
0 · tag"OPTION"Constant tag.
1 · nameIdentifierThe option name.
2 · typeTextThe option's payload type.

LET

["LET", "label", "Text",
  ["call", ["Maths.Integer.ToString", [], [["reference", "count"]]]]
]
LET keyword JSON array definition
PositionTypeDescription
0 · tag"LET"Constant tag.
1 · nameIdentifierThe bound name.
2 · typeTextThe value's type.
3 · valueAssignmentValue union["reference", name] or ["call", FunctionCall].

STATE

["STATE", "count", "Maths.Integer", ["constant", ["literal", ["integer", 0]]], false]
STATE keyword JSON array definition
PositionTypeDescription
0 · tag"STATE"Constant tag.
1 · nameIdentifierThe cell's name.
2 · typeTextThe cell's type.
3 · initialAssignmentValue or nullThe starting value, or null.
4 · lockableLogic.MaybeWhether the cell is lockable.

REVERSE

["REVERSE", "submit", "App.Profile",
  [["SET", "saved", "response"]],
  [
    ["LET", "response", "Network.Web.Response",
      ["call", ["Network.Web.Client.Post", [], [["reference", "profile"]]]]]
  ]
]
REVERSE keyword JSON array definition
PositionTypeDescription
0 · tag"REVERSE"Constant tag.
1 · nameIdentifierThe reverse's name.
2 · typeTextThe type being written back.
3 · settersarray of SETThe write-backs into outer state.
4 · bodyarray of BodyCommandThe work done before the write.

SET

["SET", "saved", "response"]
SET keyword JSON array definition
PositionTypeDescription
0 · tag"SET"Constant tag.
1 · outerSettableTextThe outer state cell to write into.
2 · innerValueTextThe inner value to write.

WITH

["WITH", "Network.Web.Client", "Network.Web.Mock", [
  ["LET", "response", "Network.Web.Response",
    ["call", ["Network.Web.Client.Post", [], [["reference", "profile"]]]]]
]]
WITH keyword JSON array definition
PositionTypeDescription
0 · tag"WITH"Constant tag.
1 · moduleTextThe module whose implementation is swapped.
2 · replacementTextThe module swapped in.
3 · bodyarray of BodyCommandThe commands the swap applies over.