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

Using jq how can I replace the name of a key with something else

$
0
0

This should be easy enough... I want to rename a few keys (ideally with jq), whatever I do seems to error though. Here is a JSON example below:

$ cat fruitfile.json
[  {"fruit": "strawberry","veg": "apple","worker": "gardener"  }]

I'd like to rename the veg key to fruit2 (or example, whatever is easiest) and also the worker key to job.

I realize this is possible in sed, but I'm trying to get to grips with jq.


Viewing all articles
Browse latest Browse all 527

Trending Articles



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