JQ

What is JQ

JQ is a command line json processor, that can streamline json parsing and filtering data. It's very helpful for debugging and quickly processing json outputs.

JQ tips and tricks

pipe it in and filter out the parameters.
A couple of examples:
jq .embeddings < ai_output.json Lists just the embedding from this particular file.

If I want all prompts, I can do: jq .prompts < ai_output.json and then the request ID without the quotes with: jq -r .id < ai_output.json

Now some cooler stuff:
List all keys from the file (including nested)

jq -r '[paths | join(".")]' ai_output.json 

Create a cleaner or smaller version of an output, in this case, no embedding:

jq '{request_id: .id, prompt: .prompt}' ai_output.json

There's a lot more to explore, but I haven't had an actual use case for most of them. You can select as if it were a database with jq 'select (.prompt | length > 1 )' ai_output


Linux - MOC