Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 738 Bytes

File metadata and controls

27 lines (18 loc) · 738 Bytes

JQ - Read and Process JSON files

# report the top level keys of a json file
jq 'keys' file.json

# if a top level key is called "entries", show only the content for that key
jq '.entries' file.json 

# show only the first 5 elements in the "entries" list, if it is a list
jq '.entries[0:5]' file.json

# list the keys of the dict that is the first element in the "entries" list
jq '.entries[0] | keys' file.json 

# show the content of the 'name' key, that is in the dict of the first element in the "entries" list
jq '.entries[0] | .name' file.json

# get the length of the "scores" list
jq '.scores | length' file.json

# get the min and max of the "scores" list
jq '.scores | min' file.json
jq '.scores | max' file.json