Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110577 > unrolled thread
| Started by | Nagy László Zsolt <gandalf@shopzeus.com> |
|---|---|
| First post | 2016-06-27 15:30 +0200 |
| Last post | 2016-06-27 06:43 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Which one is the best JSON parser? Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-27 15:30 +0200
Re: Which one is the best JSON parser? Ned Batchelder <ned@nedbatchelder.com> - 2016-06-27 06:43 -0700
| From | Nagy László Zsolt <gandalf@shopzeus.com> |
|---|---|
| Date | 2016-06-27 15:30 +0200 |
| Subject | Re: Which one is the best JSON parser? |
| Message-ID | <mailman.29.1467034250.2358.python-list@python.org> |
On 2016-06-23, MRAB <python@mrabarnett.plus.com> wrote:
>> On 2016-06-23 21:58, David Shi via Python-list wrote:
>>> Can any one tell me?
>>> Regards.
>>> David
>>>
>> There's one in the standard library.
> Which has always worked fine for me...
Which always reminds me:
>>> import json
>>> d = {0:1, False:2}
>>> d
{0: 2}
>>> json.dumps(d)
'{"0": 2}'
>>>
WAT :-)
[toc] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2016-06-27 06:43 -0700 |
| Message-ID | <0cb3a4f5-2273-42b5-b8b9-de4bc7898e0f@googlegroups.com> |
| In reply to | #110577 |
On Monday, June 27, 2016 at 9:31:04 AM UTC-4, Nagy László Zsolt wrote:
> On 2016-06-23, MRAB <python@mrabarnett.plus.com> wrote:
> >> On 2016-06-23 21:58, David Shi via Python-list wrote:
> >>> Can any one tell me?
> >>> Regards.
> >>> David
> >>>
> >> There's one in the standard library.
> > Which has always worked fine for me...
> Which always reminds me:
>
> >>> import json
> >>> d = {0:1, False:2}
> >>> d
> {0: 2}
> >>> json.dumps(d)
> '{"0": 2}'
> >>>
>
> WAT :-)
Python's booleans being ints is a remnant of history. I agree it would be
better for True and False to be unrelated to 1 and 0.
The conversion of 0 to "0" is because JSON can only use strings for keys in
objects. It might be better for dumps to fail if a non-string key is
encountered, but I'm not sure.
--Ned.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web