← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 gvanrossum
收信人 amaury.forgeotdarc, barry, eli.bendersky, eric.snow, ethan.furman, ezio.melotti, gvanrossum, ncoghlan, pitrou, rhettinger
日期 2013-06-21.14:49:03
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1371826143.64.0.582581016441.issue18264@psf.upfronthosting.co.za>
In-reply-to
内容
The proposal to change json from using repr() to str() has unknown dangers.

I don't want the str() of IntEnum to return just the decimal string (e.g. "42"), since that breaks half of the usefulness of using the enum in the first place -- people will write print(x) and be confused.

Unfortunately the json module doesn't have a way to define *in the object* how to customize its serialization -- this is always done in the json encoder/decoder.  Maybe we can add something to the JSON encoder and decoder class that looks for a special method, e.g. __json_encode__ etc.?  (OR maybe this would be a use case for PEP 443?)
历史
日期 用户 动作 参数
2013-06-21 14:49:03gvanrossum修改recipients: + gvanrossum, barry, rhettinger, amaury.forgeotdarc, ncoghlan, pitrou, ezio.melotti, eli.bendersky, ethan.furman, eric.snow
2013-06-21 14:49:03gvanrossum修改messageid: <1371826143.64.0.582581016441.issue18264@psf.upfronthosting.co.za>
2013-06-21 14:49:03gvanrossum链接issue18264 messages
2013-06-21 14:49:03gvanrossum创建