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

  • Re-processing failed firehose batches
  • Replicating sequences with pglogical
  • Terraforming an RDS Proxy
  • Cross-account pull for a Lambda function
  • Encrypting external config sections (using PowerShell)

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!
    • Already have a WordPress.com account? Log in now.
    • Look on my works, ye Mighty, and despair!
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar