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

How to get parent node from JSON?

$
0
0

[Update my question little bit]

I have below JSON in a test.json file. And I'm trying to figure out how to get all the root names, who's values are completely dynamic in nature.

{"result_set": {"/api/device/4756": {"name": "Arbitrator","ip": "127.0.0.1","hostname": "acme.arbitrate.com"        },"/api/device/4757": {"name": "Auditor","ip": "127.0.0.2","hostname": "acme.auditor.com"        },"/api/device/4758": {"name": "Augumentor","ip": "127.0.0.3","hostname": "acme.augumentor.com"        }    }}

So far I've tried but it doesn't return what I'm looking for....

cat test.json | jq -r '["names"], (.result_set | [])'

I'm looking for a result that looks like below ...

/api/device/4756, Arbitrator, 127.0.0.1, acme.arbitrate.com/api/device/4757, Auditor, 127.0.0.2, acme.auditor.com/api/device/4758, Augumentor, 127.0.0.3, acme.augumentor.com

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>