[issue29992] Expose parse_string in JSONDecoder

2022-02-16 Thread Inada Naoki
Inada Naoki added the comment: > Generally speaking, parsing some things as decimal or datetime are schema > dependent. Totally agree with this. > In order to provide maximal flexibility it would be much nicer to have a > streaming interface available (like SAX for XML parsing), but that

[issue29992] Expose parse_string in JSONDecoder

2022-02-16 Thread Tobias Oberstein
Tobias Oberstein added the comment: > It's unlikely that you would want to parse every string that looks enough > like a decimal as a decimal, or that you would want to pay the cost of > checking every string in the whole document to see if it's a decimal. fwiw, yes, that's what I do, and

[issue29992] Expose parse_string in JSONDecoder

2018-01-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Bob. -- ___ Python tracker ___

[issue29992] Expose parse_string in JSONDecoder

2018-01-11 Thread Bob Ippolito
Bob Ippolito added the comment: Generally speaking, parsing some things as decimal or datetime are schema dependent. It's unlikely that you would want to parse every string that looks enough like a decimal as a decimal, or that you would want to pay the cost of checking

[issue29992] Expose parse_string in JSONDecoder

2018-01-10 Thread Adrián Orive
Adrián Orive added the comment: Third file -- Added file: https://bugs.python.org/file47376/__init__.py ___ Python tracker ___

[issue29992] Expose parse_string in JSONDecoder

2018-01-10 Thread Adrián Orive
Adrián Orive added the comment: Second file -- Added file: https://bugs.python.org/file47375/decoder.py ___ Python tracker ___

[issue29992] Expose parse_string in JSONDecoder

2018-01-10 Thread Adrián Orive
Adrián Orive added the comment: I found the same problem. My case seems to be less exotic, as what I'm trying to do is parse some of these strings into decimal.Decimal or datetime.datetime formats. Returning a decimal as a string is becoming quite common in REST APIs to

[issue29992] Expose parse_string in JSONDecoder

2017-05-02 Thread Bob Ippolito
Bob Ippolito added the comment: That's not a very convincing argument. Python 2 only returns byte strings if the input is a byte string and the contents of the string are all ASCII. Facilitating that sort of behavior in 3 would probably cause more issues than it solves. --

[issue29992] Expose parse_string in JSONDecoder

2017-05-01 Thread Levi Cameron
Levi Cameron added the comment: A less exotic use case than oberstet's: Converting code from python 2 -> 3 and trying to maintain python 2 behaviour of returning all strings as bytes rather than unicode strings. obsertet's solution works but is very much tied to the current implementation.

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Bob Ippolito
Bob Ippolito added the comment: I agree with that sentiment. If we were to want to support this use case I would rather put together a coherent way to augment the parsing/encoding of anything than bolt it on to what we have. -- ___ Python tracker

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- components: +Library (Lib) versions: +Python 3.7 ___ Python tracker ___

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I agree with Serhiy that the JSON module is already complex enough that adding more features will have a negative net effect on usability. Bob, what do you think? -- assignee: -> bob.ippolito nosy: +bob.ippolito

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Tobias Oberstein
Tobias Oberstein added the comment: I agree, my use case is probably exotic: transparent roundtripping of binaries over JSON using a beginning \0 byte marker to distinguish plain string and base64 encoded binaries. FWIW, I do think however that adding "parse_string" kw param to the ctor of

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: JSONDecoder constructor already has too much parameters. Adding new parameters will decrease usability. For such uncommon case I think overriding a method in a subclass is the best solution. -- nosy: +ezio.melotti, rhettinger, serhiy.storchaka

[issue29992] Expose parse_string in JSONDecoder

2017-04-05 Thread Tobias Oberstein
New submission from Tobias Oberstein: Though the JSONDecoder already has all the hooks internally to allow for a custom parse_string (https://github.com/python/cpython/blob/master/Lib/json/decoder.py#L330), this currently is not exposed in the constructor JSONDecoder.__init__. It would be