...
However, dots are already allowed as part of element names on JSON (i.e. Schemaless) records(e.g. {
'nested.key': {'value':42}}
).
Instead of escaping dots with backslashes — which in JSON configurations will lead to unfriendly configurations — it's proposed to follow a similar approach as the JSONata[2] to add field names with dots using backticks, e.g. `nested.key`.valueBackslashes can be used to escape existing backticks that are part of the field name – expecting that backticks are far less usual than dots included on field names.
[1] https://stedolan.github.io/jq/manual/#Basicfilters
...
> Field references containing whitespace or reserved tokens can be enclosed in backticks
Examples
Rules
- 1. If field names do not contain dots, then only use dots to represent nested fields.
- 2. If field names contain dots, then:
- wrap the field name with a backtick pair by
- adding an opening backtick at the beginning of the field name (beginning of path, or after a dot)
- adding a closing backtick at the end of the field name (end of the path, or before the next dot)
- if a field is wrapped and doesn't contain dots, is processed the same way: field name within the wrapping backticks is used
- wrap the field name with a backtick pair by
- 3. If field name includes backticks, then:
- if the backticks are in a wrapping position (opening or closing a field name), then need to be escaped with backslash
- else, backticks do not require escape
Examples
Scenario | Field name | Nested path |
---|---|---|
| foo.bar.baz | foo: |
2. Field names including dots | foo.`bar.baz` | foo: bar.baz: val |
2.1 Using backticks within a field name without dots | foo.`bar`.baz | foo: bar: baz: val |
3. Field names including backticks | foo.ba`r.baz | foo: ba`r: baz: val |
3.1. Field names including backticks at wrapping position | foo.`bar\`.\`baz` | foo: bar`.`baz: val |
3.2. Field names including dots and backticks between a backtick pair | foo.`b`ar.baz` | foo: b`ar.baz: val |
3.3. Field names wrapped by backticks | foo.``bar``.baz | foo: `bar`: baz: |
a:
b:
c: val
a:
b.c: val
a:
b`:
c: val
a:
b`.c: val
a:
`b`:
c:val |
Affected SMTs
These SMTs will include support for nested structure:
...