Skip to content

Instantly share code, notes, and snippets.

@ctataryn
Created June 24, 2019 22:48
Show Gist options
  • Save ctataryn/1d11da25c2165ff75ed8d99a27cd1768 to your computer and use it in GitHub Desktop.
Save ctataryn/1d11da25c2165ff75ed8d99a27cd1768 to your computer and use it in GitHub Desktop.
Turn array of objects into map using jq

Given:

[{id: "1234", name: "foo"}, {id: "5678", name: "bar"}, ... ]

jq: map( { (."id"): (.) }) | add

Produces:

{
  "1234": { id: "1234", name: "foo" },
  "5678": { id" "5678", name: "bar" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment