SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 3,291 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top