django-rest-framework-msgpack
django-rest-framework-msgpack copied to clipboard
msgpack renderer behaves too differently from the builtin json renderer
This project encodes Decimal like this:
elif isinstance(obj, decimal.Decimal):
return {'__class__': 'decimal', 'as_str': str(obj)}
While DRF json renderer encodes Decimal like this:
elif isinstance(obj, decimal.Decimal):
# Serializers will coerce decimals to strings by default.
return float(obj)
I think it is a terrible idea that they behave so differently, since it means you cannot easily switch from json to msgpack. I just tried to change, and it completely breaks my client.
@gjcarneiro thanks for checking this annoyance. I'm looking into this as soon as I find some spare time.
@gjcarneiro looks like it was that way at the point that the library was created.