Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "A": [
- {
- "B": 0,
- "C": 1
- }
- ],
- "D": [
- {
- "E": 2,
- "F": 4}
- ]
- }
- import json
- from pathlib import Path
- path = Path('newtest.json')
- data = json.loads(path.read_text(encoding='utf-8'))
- data['A'].append({'B':50,'C':50})
- path.write_text(json.dumps(data,sort_keys=True, indent=4, separators=(',', ': ')), encoding='utf-8')
- {
- "A": [
- {
- "B": 0,
- "C": 1
- },
- {
- "B": 50,
- "C": 50
- }
- ],
- "D": [
- {
- "E": 2,
- "F": 4
- }
- ]
- }
Add Comment
Please, Sign In to add comment