Replies: 1 comment
-
|
You are asking for a function commonly referred to as a Cartesian Product to get that kind of output. You can do this by using the ExamplesList of Lists$ yq '[.a[] as $a | .b[] as $b | [ $a, $b ]]' data.yaml
- - "A0"
- "b0"
- - "A0"
- "b1"
- - "A1"
- "b0"
- - "A1"
- "b1"
- - "A2"
- "b0"
- - "A2"
- "b1"Use flow style for single line inner list output$ yq '[.a[] as $a | .b[] as $b | [ $a, $b ] | . style="flow"]' data.yaml
- ["A0", "b0"]
- ["A0", "b1"]
- ["A1", "b0"]
- ["A1", "b1"]
- ["A2", "b0"]
- ["A2", "b1"]List of Objects$ yq '[.a[] as $a | .b[] as $b | { "a": $a, "b": $b }]' data.yaml
- a: "A0"
b: "b0"
- a: "A0"
b: "b1"
- a: "A1"
b: "b0"
- a: "A1"
b: "b1"
- a: "A2"
b: "b0"
- a: "A2"
b: "b1" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Is there a way to do this kind of array product for all values in the doc:
so the result is:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions