...
1exec cue export fold.cue
2cmp stdout expect-stdout-cue
3
4-- frontmatter.toml --
5title = "Folding of Single-Field Structs"
6description = ""
7
8-- text.md --
9In JSON, one defines nested values, one value at a time.
10Another way to look at this is that a JSON configuration is a set of
11path-value pairs.
12
13In CUE one defines a set of paths to which to apply
14a concrete value or constraint all at once.
15Because of CUE's order independence, values get merged
16
17This example shows some path-value pairs, as well as
18a constraint that is applied to those to validate them.
19<!--
20This also gives a handy shorthand for writing structs with single
21members.
22-->
23
24-- fold.cue --
25// path-value pairs
26outer: middle1: inner: 3
27outer: middle2: inner: 7
28
29// collection-constraint pair
30outer: [string]: inner: int
31
32-- expect-stdout-cue --
33{
34 "outer": {
35 "middle1": {
36 "inner": 3
37 },
38 "middle2": {
39 "inner": 7
40 }
41 }
42}
View as plain text