forked from LBRYCommunity/lbry-sdk
handle decimals in jsonrpc return
This commit is contained in:
parent
52024986ee
commit
6821676853
1 changed files with 5 additions and 1 deletions
|
@ -417,6 +417,10 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
return server.NOT_DONE_YET
|
||||
|
||||
def _cbRender(self, result, request, id, version):
|
||||
def default_decimal(obj):
|
||||
if isinstance(obj, Decimal):
|
||||
return float(obj)
|
||||
|
||||
if isinstance(result, Handler):
|
||||
result = result.result
|
||||
|
||||
|
@ -428,7 +432,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
result = (result,)
|
||||
# Convert the result (python) to JSON-RPC
|
||||
try:
|
||||
s = jsonrpclib.dumps(result, version=version)
|
||||
s = jsonrpclib.dumps(result, version=version, default=default_decimal)
|
||||
except:
|
||||
f = jsonrpclib.Fault(self.FAILURE, "can't serialize output")
|
||||
s = jsonrpclib.dumps(f, version=version)
|
||||
|
|
Loading…
Reference in a new issue