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.

Author oberstet
Recipients Adrián Orive, Levi Cameron, bob.ippolito, ezio.melotti, oberstet, rhettinger, serhiy.storchaka
Date 2022-02-16.16:09:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645027784.83.0.531657394586.issue29992@roundup.psfhosted.org>
In-reply-to
Content
> 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 yes, it needs to check every string

https://github.com/crossbario/autobahn-python/blob/bc98e4ea5a2a81e41209ea22d9acc53258fb96be/autobahn/wamp/serializer.py#L410

> Returning a decimal as a string is becoming quite common in REST APIs to ensure there is no floating point errors.

exactly. it is simply required if money values are involved.

since JSON doesn't have a native Decimal, strings need to be used (the only scalar type in JSON that allows one to encode the needed arbitrary precision decimals)

CBOR has tagged decimal fraction encoding, as described in RFC7049 section 2.4.3.

fwiw, we've added roundtrip and crosstrip testing between CBOR <=> JSON in our hacked Python JSON, and it works

https://github.com/crossbario/autobahn-python/blob/bc98e4ea5a2a81e41209ea22d9acc53258fb96be/autobahn/wamp/test/test_wamp_serializer.py#L235
History
Date User Action Args
2022-02-16 16:09:44oberstetsetrecipients: + oberstet, rhettinger, bob.ippolito, ezio.melotti, serhiy.storchaka, Levi Cameron, Adrián Orive
2022-02-16 16:09:44oberstetsetmessageid: <1645027784.83.0.531657394586.issue29992@roundup.psfhosted.org>
2022-02-16 16:09:44oberstetlinkissue29992 messages
2022-02-16 16:09:44oberstetcreate