Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ Encoders MUST quote a string value if any of the following is true:
- It contains the relevant delimiter – the active delimiter for inline array values, tabular row cells, and keyed entry-row cells; the document delimiter for object field values (§11.1, which is authoritative for delimiter-aware quoting).
- It equals "-" or starts with "-" (any hyphen at position 0).
- It equals "#" or starts with "#" (any number sign at position 0).
- It is a root primitive (§5) and starts with U+FEFF (§12).

Otherwise, the string MAY be emitted without quotes. Unicode, emoji, and strings with internal (non-leading/trailing) spaces are safe unquoted provided they do not violate the conditions.

Expand Down
8 changes: 8 additions & 0 deletions tests/fixtures/encode/primitives.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@
"input": "#hello",
"expected": "\"#hello\"",
"specSection": "7.2"
},
{
"name": "quotes a root string starting with U+FEFF",
"input": "\ufeff8",
"expected": "\"\ufeff8\"",
"specSection": "7.2",
"note": "Unquoted, a decoder would remove the U+FEFF as a byte-order mark (§12) and read the number 8",
"minSpecVersion": "4.1"
}
]
}
Loading