cue-lang / docs-and-content

A place to discuss, plan, and track documentation on cuelang.org
5 stars 1 forks source link

howto: add multiple input files to a list #5

Open myitcv opened 9 months ago

myitcv commented 9 months ago

Based on https://github.com/cue-lang/cue/discussions/2582


I am trying to find out if merging multiple JSON files which only have one object in it to a list is possible with CUE. This seems like the simplest thing but I am not understanding correctly.

Consider the following file structure:

../
./
merge.cue
input1.json
input2.json
input3.json

In merge.cue I have a schema

#Foo: {
  oof: string
  rab: string
}

// My non-working output is
foos: [...#Foo]

I want the output to be

{
  "foos": [
    { "oof": "", "rab": "" },
    # and so on
  ]

I have been running with the command cue eval merge.cue *.json --out json

Is this possible - and if so, can someone point me in the right direction.

Please, and thanks. 👐🏻

jpluscplusm commented 6 months ago

@myitcv Do you feel this issue should result in additional content from the differently-titled but identical issue #7?