import decimal


def decimal_default(obj):
    """Properly parse out the Decimal datatypes into proper int/float types."""
    if isinstance(obj, decimal.Decimal):
        if obj % 1:
            return float(obj)
        return int(obj)
    raise TypeError