I'm trying to edit a json file using shell scripts without using jq. I found the necessary python code to do so, Python read JSON file and modify, but when I try to execute all of it in a single line in shell, I receive a syntax error. I wrote the following command:
export data = `python -c "import json;import os;filename='test.json';with open(filename, 'r') as f:data = json.load(f) data['id'] = 'abc';os.remove(filename);with open(filename, 'w') as f:json.dump(data, f, indent=4)"`
Any suggestions?