Skip to content

Commit 00daa35

Browse files
committed
allow trailing comma in arrays
1 parent d55e615 commit 00daa35

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,45 @@ CESON is mostly like JSON, but:
1111
the ECMAScript spec, to avoid problems with Unicode line terminators.
1212
* For increased compatibility, outside of values, CESON parsers should
1313
ignore characters that are whitespace in JSON but not in ECMAScript.
14-
* CESON defines `simplespace` as any combination of `\t \r\n`
15-
(U+:TODO:).
14+
* CESON defines "simplespace" as any combination of `\t \r\n`
15+
(U+0009, U+0020, U+000D, U+000A).
16+
* A "blank line" is a line that consists entirely of an optional BOM
17+
(only valid if it's the first line) and optional simplespace.
18+
* More definitions:
19+
* "Line text" is the minimal continuous substring of a line that precludes
20+
it from being a blank line. (Everything except first line BOM, leading
21+
and trailing simplespace.) Blank lines don't have line text.
22+
* A "container head" is any bracket character that, in JSON, could mark
23+
the start of a data container. (At time of writing: `[` and `{`)
24+
A "container tail" is any bracket character that, in JSON, could mark
25+
the end of a data container. (At time of writing: `]` and `}`)
1626
* Line comments and block comments work as in ECMAScript, but with some
1727
restrictions for easier parsing.
18-
* In the line where a comment starts, in front of that comment,
19-
the only acceptable characters are:
20-
* simplespace
21-
* byte order marks (so you don't have to care whether they are whitespace)
22-
* commas and
23-
* opening brackets that, in JSON, could open a data container.
24-
* In the line where a block comment ends, any remainder of that line may
25-
only consist of
26-
* simplespace
27-
* commas and
28-
* closing brackets that, in JSON, could close a data container.
28+
* In lines where a comment starts, line text in front of that line's
29+
first comment is restricted to any combination of simplespace, commas,
30+
and container heads.
31+
* The end of each block comment can be followed by optional simplespace,
32+
after which it must be followed by either:
33+
* end of line (comment is the last part of line text), or
34+
* start of another block comment, or
35+
* any combination of simplespace, commas, and container tails.
2936
* You can continue a string in a new line by adding its parts with the plus
3037
operator (`+`).
31-
* Except for simplespace and byte order marks, the plus sign has to be
32-
at the start or end of a line. A line can have plus signs on both sides.
33-
* Whitespace after the plus sign is allowed only if that whitespace is
34-
followed by a string part.
35-
* The validity and effect of commas at the end of data containers is
36-
inherited from ECMAScript.
38+
* The plus sign has to be at the start or end of line text.
39+
A line can have plus signs on both sides of its line text.
40+
* Commas at the end of data containers, inside them:
41+
* A comma at the end of line text has no effect if the next line text
42+
starts with a container tail.
43+
* For all other cases of commas at the end of data containers, their
44+
validity and effect is inherited from ECMAScript.
45+
3746

3847

3948
Related projects
4049
================
50+
4151
* [JSONv5](http://json5.org/): A lot more flexible, and thus a lot harder
42-
to safely handle with low-level tools like `sed`.
52+
to safely handle with low-level tools like [sed](http://sed.sf.net/).
4353
* [strip-json-comments](https://github.com/sindresorhus/strip-json-comments)
4454

4555

0 commit comments

Comments
 (0)