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

How to copy field from nested object inside array

$
0
0

My json input is:

{"zoo": [   { "room": { "name": "x" }, "gpu": { "id": "fish",  "sum": 0 } },   { "room": { "name": "y" }, "gpu": { "id": "zebra", "sum": 797 } }  ]}

I need to copy from zebra's sum into fish's sum. So, the output will be looked like:

{"zoo": [   { "room": { "name": "x" }, "gpu": { "id": "fish",  "sum": 797 } },   { "room": { "name": "y" }, "gpu": { "id": "zebra", "sum": 797 } }  ]}

But, I could not know the order of the table, so, I could not use the tables index. Actually, I need to do it be the field "name".


Viewing all articles
Browse latest Browse all 582

Trending Articles



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