...
1exec cue export json.cue
2cmp stdout expect-stdout-cue
3
4-- frontmatter.toml --
5title = "JSON Superset"
6description = ""
7
8-- text.md --
9CUE is a superset of JSON.
10It adds the following conveniences:
11
12- C-style comments,
13- quotes may be omitted from field names without special characters,
14- commas at the end of fields are optional,
15- comma after last element in list is allowed,
16- outer curly braces are optional.
17
18<!--
19{{< alert color="info">}}
20CUE borrows a trick from Go to make commas optional:
21the formal grammar still requires commas,
22but the scanner inserts commas according to a small set
23of simple rules.
24{{< /alert >}}
25-->
26
27JSON objects are called structs in CUE.
28An object member is called a field.
29
30-- json.cue --
31one: 1
32two: 2
33
34// A field using quotes.
35"two-and-a-half": 2.5
36
37list: [
38 1,
39 2,
40 3,
41]
42
43-- expect-stdout-cue --
44{
45 "one": 1,
46 "two": 2,
47 "two-and-a-half": 2.5,
48 "list": [
49 1,
50 2,
51 3
52 ]
53}
View as plain text