Skip to content
  • Home
  • About

Look on my works, ye Mighty, and despair!

jq

Array projection using jq

March 16, 2022Graham HayLeave a comment

jq is an easy way to manipulate json, for example an API response:

curl "https://something.com/api" -d '{...}' | jq '.'

If you have an array of objects:

[{
    "id": 1,
    ...
}, {
    "id": 2,
    ...
}]

and want to extract a single field, you can use map:

curl ... | jq 'map(.[] | .id)'
[
    1,
    2
]
jq

Category Cloud

Ansible AWS Bootstrap Cowboy Deployment Docker Elm Erlang Express.js gen_statem Golang JavaScript jenkins Lambda Logging MbUnit Node.js NuGet OpenRasta Postgresql PowerShell Redshift ReSharper StructureMap Syn TeamCity Testing TLA+ Unit Testing VirtualBox

Top Posts & Pages

  • Building a Tic Tac Toe game with Cowboy & websockets (Part 2)
  • Multi-stage docker with nodejs
  • Ansible & systemctl daemon-reload
  • Flattening json arrays, with Athena
  • Ansible templates and urlencode

Recent Posts

  • Add newlines to Firehose transform lambda
  • Flattening json arrays, with Athena
  • Using SSM with Ansible
  • Batch closing PRs
  • Cross-region pull for a lambda function
Blog at WordPress.com.
  • Subscribe Subscribed
    Look on my works, ye Mighty, and despair!

    Have a WordPress.com account? Log in now.

  • Look on my works, ye Mighty, and despair!
    View site in Reader
    Manage subscriptionsSign upLog in
    Report this content
    Collapse this bar