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:
color #color blue point #point [1 2]
color #color blue point #point [1 2]
{
"color": {
"#color": "blue"
},
"point": {
"#point": [
1,
2
]
}
}
[#color blue #point [1 2] #flag true #nothing null]
[#color blue #point [1 2] #flag true #nothing null]
[
{
"#color": "blue"
},
{
"#point": [
1,
2
]
},
{
"#flag": true
},
{
"#nothing": null
}
]
The payload may be any value, including another tagged element:
#outer #inner [1 2]
#outer #inner [1 2]
{
"#outer": {
"#inner": [
1,
2
]
}
}
Tagged-element payloads participate in the same width calculation:
#values [item00 item01 item02 item03 item04 item05 item06 item07 item08 item09 item10 item11 item12 item13 item14 item15 item16 item17 item18 item19 item20 item21]
#values [item00 item01 item02 item03 item04 item05 item06 item07 item08 item09 item10 item11 item12 item13 item14 item15 item16 item17 item18 item19 item20 item21]
{
"#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:
This rule also applies when the payload is boolean; tagged-element notation takes precedence over boolean tag-group notation for these single-key objects:
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.
value #person { name Ada age 36}
value #person {age 36 name Ada}
{
"value": {
"#person": {
"name": "Ada",
"age": 36
}
}
}
A leading # in a string must be quoted. A # inside a string is ordinary text:
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 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.