Allow using a custom JSON encoder in jwt.encode()
Example
import json
import decimal
import jwt
class CustomJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
return float(o)
return super(CustomJSONEncoder, self).default(o)
data = {
'some_decimal': decimal.Decimal('2.2')
}
token = jwt.encode(data, 'secret', json_encoder=CustomJSONEncoder)