JQ: Filtering for keys
with_entries/1
is your friend, e.g.:
.activities | with_entries( select(.value | has("stop_time_utc") ) )
produces:
{ "-KSndgjqvmQkWVKHCpLh": { "create_device": "...", "stop_time_utc": "2016-11-01T23:08:08Z" }, "-KSptboGjo8g4bieUbGM": { "create_device": "...", "stop_time_utc": "2017-01-17T23:08:08Z" }
It's now easy to add additional selection criteria, extract the key names of interest, etc. For example:
.activities| with_entries( select( (.value.stop_time_utc? | fromdateiso8601?) < now ) )| keys