Get the latest 5 events

Sort by timestamp, newest first, and take the first 5

jq 'sort_by(.timestamp) | reverse | .[0:5]' events.json

tool
jq17 commands
tags
jq

More jq commands

  • jq -r '.[] | [.id, .name, .status] | @csv' data.json

    Print id, name and status as CSV lines

  • jq '[.[] | . + {"env": "prod"}]' items.json

    Add env: prod to every array item

  • jq 'walk(if type == "string" then ascii_downcase else . end)' data.json

    Convert every string value in the document to lowercase

  • cat data.json | jq '.'

    Format and colorize a JSON file

  • cat data.json | jq '.items[] | select(.status == "Running")'

    Select items whose status field equals Running

all 17 jq commands