json.dump() serializes a Python value as JSON and writes the resulting string to a file-like object with a write() method. section 22.3.1
Write a weather report
outfile = open("weather_01.json", "w") json.dump(weather, outfile) outfile.close() Unlike json.dumps(weather), which returns the serialized string, json.dump() writes it directly to outfile.
Use the related options and functions deliberately:
- Use json.dumps() when the serialized JSON should remain a string instead of being written to a file. section 22.3.1
- Do not repeatedly dump separate objects into one file and expect json.load() to parse the whole file; store them in a list or enclosing object instead. section 22.3.1


