From 68216768539f9504e5bbf8f5f61fe539ca684eda Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 28 Jul 2016 18:12:54 -0400 Subject: [PATCH] handle decimals in jsonrpc return --- lbrynet/lbrynet_daemon/LBRYDaemon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index f32b5c9aa..a89bee25c 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -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)