blob: b7815b0da7bf93856437fe341d0a951b95c2a220 [file] [log] [blame]
cue export json.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "JSON Superset"
description = ""
-- text.md --
CUE is a superset of JSON.
It adds the following conveniences:
- C-style comments,
- quotes may be omitted from field names without special characters,
- commas at the end of fields are optional,
- comma after last element in list is allowed,
- outer curly braces are optional.
<!--
{{< alert color="info">}}
CUE borrows a trick from Go to make commas optional:
the formal grammar still requires commas,
but the scanner inserts commas according to a small set
of simple rules.
{{< /alert >}}
-->
JSON objects are called structs in CUE.
An object member is called a field.
-- json.cue --
one: 1
two: 2
// A field using quotes.
"two-and-a-half": 2.5
list: [
1,
2,
3,
]
-- expect-stdout-cue --
{
"list": [
1,
2,
3
],
"one": 1,
"two": 2,
"two-and-a-half": 2.5
}