Stage 3 · Lesson 8 of 8
JSON on the command line with jq
JSON is the text format most and many tools use for data. jq is the standard for the terminal. jq . prints JSON neatly indented. .name picks one field.
.items[] goes through each item in a list. select(.active) keeps only the items that match a condition. -r prints plain text without the quote marks.
Together with curl, which fetches a web address, you can question an API from the shell: curl -s URL | jq '.[] | .title'. Scripts use jq the same way to pull values out of and command output. Build filters one step at a time, as with pipelines.
Common trapusing and cut on JSON, which breaks as soon as formatting or field order changes.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The data wrangling lecture walks through grep, sed, awk and regular expressions on real logs
- BookFreeThe Linux Command Line
William Shotts · Beginner
Clear chapters on text processing, regular expressions and searching for files