enthuguy
asked on
find and replace value in json file in linux
Hi bash experts.
Could you kindly help with this please.
Have attached
Thanks in advance
config_after.json
config_before.json
sample.properties
Could you kindly help with this please.
- Have a json file which I would like to automate replacing some values.
- Value would come from a property file.
- I'm trying to avoid introducing a token in the source json file and use sed to replace it.
- Would really like to check for name and then replace value portion, may be sed will use regex
- Since I dont have control on the file, I prefer this.
- Very worst case I can introudce tocken and use sed to replace if that is safe and simple
Have attached
- json file (before)
- json file (after)
- sample property file
Thanks in advance
config_after.json
config_before.json
sample.properties
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As noci said, this is really not something you can do easily or reliably in bash. Personally I would use Perl but python would work as well (and likely other languages).
i should have mentioned perl as well... (Python and Node-js come to mind first for json as they both use it for native format).