#!/usr/bin/env sh
# Output JSONL from an array- or object-of-objects

while getopts hx opt; do
    case $opt in
    h) awk 'NR == 1 {next} /^$/ {exit} {print substr($0, 3)}' "$0"; exit;;
    x) set -x;;
    esac
done
shift $(( OPTIND - 1 ))

jq -c '
if type == "array" then .[]
elif type == "object" then to_entries[] | {(.key): (.value)}
end
'
