Select non-null fields

Filter array elements where value is not null

jq '[.[] | select(.value != null)]' data.json

tool
jq17 commands
tags
jq

More jq commands

  • jq 'group_by(.status) | map({status: .[0].status, count: length})' data.json

    Count records grouped by status field

  • jq 'flatten(1)' nested.json

    Flatten one level of nested arrays

  • jq 'INDEX(.[]; .id)' items.json

    Build an object keyed by the id field

  • jq -s '.[0] * .[1]' base.json override.json

    Deep merge two JSON objects (right wins on conflicts)

  • jq '.config?.database?.host // "localhost"' config.json

    Optional chaining with fallback default value

all 17 jq commands