9. Tagged elements
Readable Object Notation

The name “tagged element” comes from the EDN format specification.

A tagged element represents an object with exactly one #-prefixed key. Its canonical spelling is #prefix value, without object braces. The prefix consumes exactly one value and is valid at the document root, in a list, or as a map member's value:

RON
color #color blue
point #point [1 2]
→
Canonical RON
color #color blue
point #point [1 2]
→
{} JSON
{
  "color": {
    "#color": "blue"
  },
  "point": {
    "#point": [
      1,
      2
    ]
  }
}
RON
[#color blue #point [1 2] #flag true #nothing null]
→
Canonical RON
[#color blue #point [1 2] #flag true #nothing null]
→
{} JSON
[
  {
    "#color": "blue"
  },
  {
    "#point": [
      1,
      2
    ]
  },
  {
    "#flag": true
  },
  {
    "#nothing": null
  }
]

The payload may be any value, including another tagged element:

RON
#outer #inner [1 2]
→
Canonical RON
#outer #inner [1 2]
→
{} JSON
{
  "#outer": {
    "#inner": [
      1,
      2
    ]
  }
}

Tagged-element payloads participate in the same width calculation:

RON
#values [item00 item01 item02 item03 item04 item05 item06 item07 item08 item09 item10 item11 item12 item13 item14 item15 item16 item17 item18 item19 item20 item21]
→
Canonical RON
#values [item00 item01 item02 item03 item04
         item05 item06 item07 item08 item09
         item10 item11 item12 item13
         item14 item15 item16 item17
         item18 item19 item20 item21]
→
{} JSON
{
  "#values": [
    "item00",
    "item01",
    "item02",
    "item03",
    "item04",
    "item05",
    "item06",
    "item07",
    "item08",
    "item09",
    "item10",
    "item11",
    "item12",
    "item13",
    "item14",
    "item15",
    "item16",
    "item17",
    "item18",
    "item19",
    "item20",
    "item21"
  ]
}

The ordinary object spelling remains valid input. The formatter converts an eligible single-key object to tagged-element notation:

RON
{#color blue}
→
Canonical RON
#color blue
→
{} JSON
{
  "#color": "blue"
}

This rule also applies when the payload is boolean; tagged-element notation takes precedence over boolean tag-group notation for these single-key objects:

RON
{#flag false}
→
Canonical RON
#flag false
→
{} JSON
{
  "#flag": false
}

A prefix contains # followed by a nonempty name, then at least one space or tab before the payload. Its name cannot contain whitespace, commas, double quotes, or any of [], {}, (), or <>. Names outside those rules remain ordinary quoted object keys. Objects with additional keys, including $comment, retain ordinary map notation.

The payload follows compact value rules even on a member line: quote a string containing spaces or commas. Container payloads may span lines, and multiline string fences remain available.

RON
#text "hello world"
→
Canonical RON
#text "hello world"
→
{} JSON
{
  "#text": "hello world"
}
RON
value #person {
  name Ada
  age 36}
→
Canonical RON
value #person {age 36
               name Ada}
→
{} JSON
{
  "value": {
    "#person": {
      "name": "Ada",
      "age": 36
    }
  }
}

A leading # in a string must be quoted. A # inside a string is ordinary text:

RON
["#color" "#" "a#b"]
→
Canonical RON
["#color" "#" a#b]
→
{} JSON
[
  "#color",
  "#",
  "a#b"
]

At the document root, #prefix value is one complete tagged element. To write several ordinary members whose keys begin with #, use explicit object braces or quote the keys. The formatter quotes such keys in an implicit root map.

RON
{#a 1 #b 2}
→
Canonical RON
"#a" 1
"#b" 2
→
{} JSON
{
  "#a": 1,
  "#b": 2
}

RON assigns no built-in meaning to any prefix. It does not evaluate a tagged element or look up its prefix as a function. An application defines what each kind of tagged element means and which payloads it accepts.