github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/doc/tutorial/basics/0_intro/55_fold.txt (about) 1 cue export fold.cue 2 cmp stdout expect-stdout-cue 3 4 -- frontmatter.toml -- 5 title = "Folding of Single-Field Structs" 6 description = "" 7 8 -- text.md -- 9 In JSON, one defines nested values, one value at a time. 10 Another way to look at this is that a JSON configuration is a set of 11 path-value pairs. 12 13 In CUE one defines a set of paths to which to apply 14 a concrete value or constraint all at once. 15 Because of CUE's order independence, values get merged 16 17 This example shows some path-value pairs, as well as 18 a constraint that is applied to those to validate them. 19 <!-- 20 This also gives a handy shorthand for writing structs with single 21 members. 22 --> 23 24 -- fold.cue -- 25 // path-value pairs 26 outer: middle1: inner: 3 27 outer: middle2: inner: 7 28 29 // collection-constraint pair 30 outer: [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 }