And, if you need to read each array item individually - you can't just use .agents[].first_name, .agents[].last_name, .agents[].attributes.charisma, .agents[].attributes.intelligence - do this and you'll get the data out of order, since jq processing all first_names, then processing all last_names, and so on.

Instead you'll get the array first, then pipe it to the next portion: .agents[] | [.first_name, .last_name, .attributes.charisma, .attributes.intelligence]

Since I wanted the output to be an array for the @csv function later, the second part is enclosed in square brackets.

Functions

jq has various functions you can use to process your data (apart from @csv, of course), e.g. [.agents[].first_name | ascii_downcase] | sort | reverse convert to lowercase, sorts the array, then reverses the array.

curl

As a side note, I needed to get the JSON data from a REST service. macOS comes with curl, which is the de facto tool for transferring data from a server over file transfer (S)FTP, web HTTP(S), mail IMAP / SMTP / POP3(S), and more!