JQ notes
Shorthand object contsuction
I kept googling for the syntax but could never find it again.
// long:
'{user: .user, title: .titles}'
// shorthand when key name matches original key name (user==.user)
'{user, title}'
// mix
'{user, title_name: .title}'
From the man page:
You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write
{user: .user, title: .title}
Because that is so common, there´s a shortcut syntax for it:{user, title}.
The long version allows to operate on they keys:
{id: .idx, metadata: .metadata.original_idx}
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus