[New-bugs-announce] [issue23123] Only READ support for Decimal in json

Anders Rundgren report at bugs.python.org
Sat Dec 27 18:10:51 CET 2014


New submission from Anders Rundgren:

jsonString = '{"t":6,"h":4.50, "g":"text","j":1.40e450}'
jsonObject = json.loads(jsonString, object_pairs_hook=collections.OrderedDict,parse_float=Decimal)
for item in jsonObject:
  print jsonObject[item]
6
4.50
text
1.40E+450

Works as expected.

However, there seems to be no way to get back to the original JSON string as far as I can tell since you have to convert Decimal to str in cls when using json.dumps which adds "" around the arguments

----------
components: Extension Modules
messages: 233139
nosy: anders.rundgren.net at gmail.com
priority: normal
severity: normal
status: open
title: Only READ support for Decimal in json
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23123>
_______________________________________


More information about the New-bugs-announce mailing list