6. Lists
Readable Object Notation

A list is an ordered sequence of values enclosed in square brackets. Its elements may have different types, and lists and maps may be nested within it. The empty list is written [].

RON
[1 true null text {name Ada} [2 3]]
→
Canonical RON
[1
 true
 null
 text
 {name Ada}
 [2 3]]
→
{} JSON
[
  1,
  true,
  null,
  "text",
  {
    "name": "Ada"
  },
  [
    2,
    3
  ]
]

When [ is alone on its line, each item line is one value, so the spaces in these names are part of each string:

RON
[
  Ada lovelace
  Grace Hopper
]
→
Canonical RON
[
  Ada lovelace
  Grace Hopper]
→
{} JSON
[
  "Ada lovelace",
  "Grace Hopper"
]

An item line on which a word begins with [, {, or < holds containers, and its words are separate items, as in compact notation. A string with a word that begins with < is therefore quoted, while < within a word stays bare:

RON
[
  "a <b"
  "x <>"
  "y < z"
  a<b
  a >b
  "<c"
]
→
Canonical RON
[
  "a <b"
  "x <>"
  "y < z"
  a<b
  a >b
  "<c"]
→
{} JSON
[
  "a <b",
  "x <>",
  "y < z",
  "a<b",
  "a >b",
  "<c"
]

When an item follows [ on the opening line, every line uses whitespace to separate items. This allows a packed list to wrap across lines:

RON
[item00 item01 item02
 item03 item04]
→
Canonical RON
[item00 item01 item02 item03 item04]
→
{} JSON
[
  "item00",
  "item01",
  "item02",
  "item03",
  "item04"
]

Each nested list is one item of the outer list; its brackets keep its own values together. The formatter leaves a compact nested list on one line when it fits, and places several such items on each outer line. If the outer list exceeds 100 columns, it balances the number of items across lines, wrapping earlier if needed to respect the width target.

Here the outer list has 24 two-number lists. Its canonical form uses five lines: five nested lists on each of the first four lines, then four on the last. The line breaks do not change the 24 items or their order:

RON
matrix [
  [0 1]
  [1 2]
  [2 3]
  [3 4]
  [4 5]
  [5 6]
  [6 7]
  [7 8]
  [8 9]
  [9 10]
  [10 11]
  [11 12]
  [12 13]
  [13 14]
  [14 15]
  [15 16]
  [16 17]
  [17 18]
  [18 19]
  [19 20]
  [20 21]
  [21 22]
  [22 23]
  [23 24]
]
→
Canonical RON
matrix [[0 1] [1 2] [2 3] [3 4] [4 5]
        [5 6] [6 7] [7 8] [8 9] [9 10]
        [10 11] [11 12] [12 13] [13 14] [14 15]
        [15 16] [16 17] [17 18] [18 19] [19 20]
        [20 21] [21 22] [22 23] [23 24]]
→
{} JSON
{
  "matrix": [
    [
      0,
      1
    ],
    [
      1,
      2
    ],
    [
      2,
      3
    ],
    [
      3,
      4
    ],
    [
      4,
      5
    ],
    [
      5,
      6
    ],
    [
      6,
      7
    ],
    [
      7,
      8
    ],
    [
      8,
      9
    ],
    [
      9,
      10
    ],
    [
      10,
      11
    ],
    [
      11,
      12
    ],
    [
      12,
      13
    ],
    [
      13,
      14
    ],
    [
      14,
      15
    ],
    [
      15,
      16
    ],
    [
      16,
      17
    ],
    [
      17,
      18
    ],
    [
      18,
      19
    ],
    [
      19,
      20
    ],
    [
      20,
      21
    ],
    [
      21,
      22
    ],
    [
      22,
      23
    ],
    [
      23,
      24
    ]
  ]
}

A root list of maps can place its first map immediately after [. Each subsequent map aligns beneath it, and each map keeps one key/value pair per line:

RON
[
  {args [0 0]
   output 0}
  {args [1 2]
   output 3}
  {args [-4 10]
   output 6}
]
→
Canonical RON
[{args [0 0]
  output 0}
 {args [1 2]
  output 3}
 {args [-4 10]
  output 6}]
→
{} JSON
[
  {
    "args": [
      0,
      0
    ],
    "output": 0
  },
  {
    "args": [
      1,
      2
    ],
    "output": 3
  },
  {
    "args": [
      -4,
      10
    ],
    "output": 6
  }
]

For eleven similarly sized items, this produces rows of four, four, and three:

RON
[item00_long item01_long item02_long item03_long item04_long item05_long item06_long item07_long item08_long item09_long item10_long]
→
Canonical RON
[item00_long item01_long item02_long item03_long
 item04_long item05_long item06_long item07_long
 item08_long item09_long item10_long]
→
{} JSON
[
  "item00_long",
  "item01_long",
  "item02_long",
  "item03_long",
  "item04_long",
  "item05_long",
  "item06_long",
  "item07_long",
  "item08_long",
  "item09_long",
  "item10_long"
]

Table of Contents

6.1. 3×3 and 4×4 matrices ↑

A game-engine transform can be represented as nested row lists. These examples use column vectors, a 60° rotation about the (1, 1, 1) axis, and uniform scale 0.999. The 3×3 matrix contains rotation and scale:

RON
[
  [0.666 -0.333 0.666]
  [0.666 0.666 -0.333]
  [-0.333 0.666 0.666]
]
→
Canonical RON
[[0.666 -0.333 0.666] [0.666 0.666 -0.333] [-0.333 0.666 0.666]]
→
{} JSON
[
  [
    0.666,
    -0.333,
    0.666
  ],
  [
    0.666,
    0.666,
    -0.333
  ],
  [
    -0.333,
    0.666,
    0.666
  ]
]

The 4×4 position-rotation-scale matrix adds translation (0.125, 0.325, -0.775) in the last column. Its homogeneous final row is 0.0 0.0 0.0 1.0:

RON
[
  [0.666 -0.333 0.666 0.125]
  [0.666 0.666 -0.333 0.325]
  [-0.333 0.666 0.666 -0.775]
  [0.0 0.0 0.0 1.0]
]
→
Canonical RON
[[0.666 -0.333 0.666 0.125]
 [0.666 0.666 -0.333 0.325]
 [-0.333 0.666 0.666 -0.775]
 [0.0 0.0 0.0 1.0]]
→
{} JSON
[
  [
    0.666,
    -0.333,
    0.666,
    0.125
  ],
  [
    0.666,
    0.666,
    -0.333,
    0.325
  ],
  [
    -0.333,
    0.666,
    0.666,
    -0.775
  ],
  [
    0.0,
    0.0,
    0.0,
    1.0
  ]
]

Both are nested arrays in JSON. The 3×3 matrix fits on one canonical line; the 4×4 matrix exceeds the 100-column target, so its rows are kept together on separate lines.

In packed mode, quote a string containing spaces. Moving the first item onto or off the opening line changes the list mode and can change the decoded value.

RON
[hello world]
→
Canonical RON
[hello world]
→
{} JSON
[
  "hello",
  "world"
]
RON
[
  hello world
]
→
Canonical RON
[
  hello world]
→
{} JSON
[
  "hello world"
]