diff options
author | BonfaceKilz | 2020-10-01 16:10:41 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-10-01 16:59:47 +0300 |
commit | 968bc7d468b2a24ded48b4deeb76b216ddb9a350 (patch) | |
tree | fa9c87a2cedf157d2ee7456bd85c94bad2916e36 /wqflask | |
parent | f0aa59dc9413daceb580938c4d706e8831bf4daa (diff) | |
download | genenetwork2-968bc7d468b2a24ded48b4deeb76b216ddb9a350.tar.gz |
Make object JSON serializable
* wqflask/wqflask/search_results.py
(SearchResultPage.gen_search_result): Some of the items is
self.trait_list are in bytes, and *json.loads* can't serialize bytes
into JSON.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/search_results.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index aa8f9e8f..ce836ce2 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -149,6 +149,10 @@ views.py). trait_dict['additive'] = "N/A" if this_trait.additive != "": trait_dict['additive'] = '%.3f' % this_trait.additive + # Convert any bytes in dict to a normal utf-8 string + for key in trait_dict.keys(): + if isinstance(trait_dict[key], bytes): + trait_dict[key] = trait_dict[key].decode('utf-8') trait_list.append(trait_dict) self.trait_list = json.dumps(trait_list) |