Created
January 9, 2019 17:17
-
-
Save antonalekseev/956f207eb05d6fa6d38157f5bde07a32 to your computer and use it in GitHub Desktop.
python-json-format created by antonalekseev - https://repl.it/@antonalekseev/python-json-format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { "value": [1, 2, 3, 4, 5] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "value": [ | |
| 2, | |
| 3, | |
| 4, | |
| 5, | |
| 6 | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| with open("file.json", "r", encoding="utf-8") as fd: | |
| content = json.load(fd) | |
| content["value"] = [int(x) + 1 for x in content["value"]] | |
| with open("file1.json", "w", encoding="utf-8") as fd: | |
| json.dump(content, fd, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment