From a42a9ca5432c70295cdd9b3e90db7861098f8054 Mon Sep 17 00:00:00 2001 From: David Sauve Date: Wed, 6 Nov 2019 14:58:26 -0800 Subject: [PATCH] Filter out null values in signature data Null values in the signature data will cause the compute box calculation to fail. Filter them out during json.loads --- jsignature/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jsignature/utils.py b/jsignature/utils.py index 2f3b585..5138dcf 100644 --- a/jsignature/utils.py +++ b/jsignature/utils.py @@ -14,9 +14,11 @@ def draw_signature(data, as_file=False): `data` can be a json object (list in fact) or a json string if `as_file` is True, a temp file is returned instead of Image instance """ + def _remove_empty_pts(pt): + return {'x': list(filter(None, pt['x'])), 'y': list(filter(None, pt['y']))} if type(data) is str: - drawing = json.loads(data) + drawing = json.loads(data, object_hook=_remove_empty_pts) elif type(data) is list: drawing = data else: