'Encode Decimal objects. If decimal object has zeros after the
decimal point then object will be serialized as `int` else `float`'

def default(self, o):

    if isinstance(o, decimal.Decimal):
        if (o == o.to_integral()):
            return int(o)
        return float(o)
    else:
        return super(EDXJSONEncoder, self).default(o)
