[issue41284] High Level API for json file parsing

2020-07-13 Thread Inada Naoki
Inada Naoki added the comment: (Off topic) There is a very common mistake in this code: ``` with oepn(filepath, 'r') as f: data = json.load(f) ``` JSON file is encoded in UTF-8. But the default text encoding is locale encoding. You should do this instead: ``` with oepn(filepath, 'rb')

[issue41284] High Level API for json file parsing

2020-07-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: json.load() is already a high level API. json.JSONDecoder is more low level API. Not every two lines of code should be added as a function in the stdlib. Also, such API would be too complex because you would need to combine parameters of open() (8

[issue41284] High Level API for json file parsing

2020-07-12 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: There was a previous issue to support filepath for json.load https://bugs.python.org/issue36378 . This just expands the json API that could already be done using one more operation. -- nosy: +ezio.melotti, rhettinger, xtreak

[issue41284] High Level API for json file parsing

2020-07-12 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi, using a file object is very common as it makes it possible to use something that is not a file, like an HTTP request or something already in memory. It makes the module serializing / de-serializing the data completely agnostic with regard to the actual

[issue41284] High Level API for json file parsing

2020-07-12 Thread Wansoo Kim
Change by Wansoo Kim : -- keywords: +patch pull_requests: +20601 stage: -> patch review pull_request: https://github.com/python/cpython/pull/21453 ___ Python tracker ___

[issue41284] High Level API for json file parsing

2020-07-12 Thread Wansoo Kim
New submission from Wansoo Kim : Many Python users use the following snippets to read Json File. ``` with oepn(filepath, 'r') as f: data = json.load(f) ``` I suggest providing this snippet as a function. ``` data = json.read(filepath) ``` Reading Json is very frequent task for python