Guest User

Untitled

a guest
Oct 23rd, 2017
3,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. {
  2. "192.168.0.129": {
  3. "username": "me",
  4. "streaming": "Spotify",
  5. "name": "John",
  6. "email": "john@gmail.com"
  7. }
  8. }
  9.  
  10. new_data = {'next_songs': ['song1', 'song2']}
  11.  
  12. with open('c.json', 'r') as json_data:
  13. data = json.load(json_data)
  14.  
  15. data.update(new_data)
  16.  
  17. with open('c.json', 'w') as json_data:
  18. json.dump(data, json_data, indent=4)
  19.  
  20. {
  21. "new_data": [
  22. "song1",
  23. "song2"
  24. ],
  25. "192.168.0.129": {
  26. "username": "me",
  27. "streaming": "Spotify",
  28. "name": "John",
  29. "email": "john@gmail.com"
  30. }
  31. }
  32.  
  33. {
  34. "192.168.0.129": {
  35. "username": "me",
  36. "streaming": "Spotify",
  37. "name": "John",
  38. "email": "john@gmail.com"
  39. "new_data": ["song1", "song2"],
  40. }
  41. }
Add Comment
Please, Sign In to add comment