django-rest-framework-msgpack icon indicating copy to clipboard operation
django-rest-framework-msgpack copied to clipboard

msgpack renderer behaves too differently from the builtin json renderer

Open gjcarneiro opened this issue 9 years ago • 2 comments

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 avatar Jun 29 '16 16:06 gjcarneiro

@gjcarneiro thanks for checking this annoyance. I'm looking into this as soon as I find some spare time.

juanriaza avatar Apr 22 '17 14:04 juanriaza

@gjcarneiro looks like it was that way at the point that the library was created.

juanriaza avatar Apr 22 '17 15:04 juanriaza