Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

jq gets objects that contain certain key

$
0
0

I'm strugling to find a solution to this, every other question I've found its quite close but still not the answer.

I've got a huge json, and it has many objects and arrays inside.What I'd like do to is extract the whole object from that json that contain a key named "time" or "time". I've found solutions related, however they just brings the key and not the whole object.

Ex 1:

    {"time": -762,"type": "chatwheel","key": "156","slot": 1,"player_slot": 1    }

Ex 2:

{"time": 888,"type": "building_kill","unit": "npc_knight","key": "npc_goodguys_tower1","slot": 7,"player_slot": 130},

Ex 3:

{"time": 681,"type": "obs_left_log","key": "[132, 124]","slot": 0,"x": 132,"y": 124,"z": 130,"entityleft": true,"ehandle": 5014545,"player_slot": 0},

Ex 4:

"purchase_log": [    {"time": -89,"key": "orb_of_venom"    },    {"time": -89,"key": "tango"    },

So, basically, I need to get not only the time key, i need to get the whole object that the key "time" belongs. (like the examples)Is there a way to do it?

Thank you


Viewing all articles
Browse latest Browse all 657

Trending Articles