Skip to content

Allow the use of strings as loading or saving paths for JSON #126629

@moyanj

Description

@moyanj

Feature or enhancement

Proposal:

Allow the use of strings as loading or saving paths for JSON.

It maintains the original API, but allows strings to be passed in when passing in file descriptors.This makes it easy to load or save JSON files.

Just like this:

import json

data = {
    "a":"b"
}
json.dump(data, "a.json")  # before: json.dump(data, open("a.json","w"))

I have submitted a pull request. #126626

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

#87623
#85456
#80559

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions