til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Find and Extract Objects

When you call a REST API, you get a JSON response. You can use jq to extract the data you need from the JSON response.

http https://jsonplaceholder.typicode.com/posts/1/comments | jq '.[] | select(.email == "Hayden@althea.biz")'
{
  "postId": 1,
  "id": 5,
  "name": "vero eaque aliquid doloribus et culpa",
  "email": "Hayden@althea.biz",
  "body": "harum non quasi et ratione\ntempore iure ex voluptates in ratione\nharum architecto fugit inventore cupiditate\nvoluptates magni quo et"
}

To get the whole set of objects, you can use the following:

http https://jsonplaceholder.typicode.com/posts/1/comments

Resources and References