-
i'm trying to collapse/flatten a structure so i can convert to tsv format. Version of yq: 4.45.1 test.yml:
this works as long as i ignore the map "user_metadata":
but i also need to flatten the map inside the array (basically remove the first level) and then select from the remaining keys. this is my desired output:
it's probably not difficult but i'm out of ideas... |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
If you want just this specific operation and not a generic flattening, you can just pick the fields yourself instead of using ❯ yq -o tsv '.[] |= {"name":.name, "email":.email, "username":.user_metadata.username}' test.yml
name email username
Miller, Tim Tim.Miller@xy.com tmiller
Jones, Karen Karen.Jones@z.com kjones |
Beta Was this translation helpful? Give feedback.
-
This should be moved to "Discussions" as it is not a bug / feature request... |
Beta Was this translation helpful? Give feedback.
-
that solves my current use case already, thx a lot! new i just missed something basic. but it would indeed be cool to have a more generic version that works with less hardcoding. |
Beta Was this translation helpful? Give feedback.
If you want just this specific operation and not a generic flattening, you can just pick the fields yourself instead of using
pick
: