Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

downcase a value in JSON

Tags:

json

lowercase

jq

I have a json file and I'm looking to lowercase PART of a value - I can jq the value and lower case the string but how do I ensure this new lowercase value gets added back into the whole file?

jq '.[].Id' file.json | awk '{print tolower($0)}'  

the above only lower cases the ID value's but now I also need to write those back into their correct spots.

like image 240
Tony Avatar asked Jul 27 '26 10:07

Tony


1 Answers

Use the update operator with ascii_downcase builtin.

jq '.[].Id |= ascii_downcase' file
like image 194
oguz ismail Avatar answered Jul 29 '26 02:07

oguz ismail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!