[Python-ideas] Add pathlib.Path.write_json and pathlib.Path.read_json

Eric V. Smith eric at trueblade.com
Mon Mar 27 10:48:17 EDT 2017


On 3/27/17 10:40 AM, Ram Rachum wrote:
> Another idea: Maybe make json.load and json.dump support Path objects?

json.dump requires open file objects, not strings or Paths representing 
filenames.

But does this not already do what you want:

Path('foo.json').write_text(json.dumps(obj))
?

Eric.


More information about the Python-ideas mailing list