Link to home
Start Free TrialLog in
Avatar of enthuguy
enthuguyFlag for Australia

asked on

find and replace value in json file in linux

Hi bash experts.

Could you kindly help with this please.

  1. Have a json file which I would like to automate replacing some values.
  2. Value would come from a property file.
  3. I'm trying to avoid introducing a token in the source json file and use sed to replace it.
  4. Would really like to check for name and then replace value portion, may be sed will use regex
  5. Since I dont have control on the file, I prefer this.
  6. Very worst case I can introudce tocken and use sed to replace if that is safe and simple


Have attached
  1. json file (before)
  2. json file (after)
  3. sample property file

Thanks in advance
config_after.json
config_before.json
sample.properties
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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).
Avatar of noci
noci

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).