save json file python
snippet in javascript

json dump to file

user8271

import json

data = {"key": "value"}

with open('data.json', 'w') as jsonfile:
    json.dump(data, jsonfile)

open json file python

user6543

import json

with open('data.txt') as json_file:
    data = json.load(json_file)

save json file python

user7093

with open('data.txt', 'w') as outfile:
    json.dump(data, outfile)

python json dump to file

user600

import json
with open('data.json', 'w') as f:
    json.dump(data, f)

json load from file python 3

user3401

import json

with open('file_to_load.json', 'r') as file:
  data = json.load(file)

save json to file

user3343

import json

data = {}

with open('data.txt', 'w') as outfile:
    json.dump(data, outfile)