From 8c4cd623c275f4903caa4caf2cbd8f7d207529d3 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 17 Jul 2023 09:49:51 +0300 Subject: Serialize to JSON with custom encoder Serialize values to JSON using the custom encoder that is aware of data types the default encoder might not be aware of. --- wqflask/wqflask/metadata_edits.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index 226a4b97..008489ce 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -382,7 +382,7 @@ View the diffs here", "success") data=MetadataAudit( dataset_id=name, editor=author, - json_data=json.dumps(diff_data), + json_data=json.dumps(diff_data, cls=CustomJSONEncoder), ), ) conn.commit() @@ -468,7 +468,7 @@ def update_probeset(name: str): data=MetadataAudit( dataset_id=data_.get("id"), editor=author, - json_data=json.dumps(diff_data), + json_data=json.dumps(diff_data, cls=CustomJSONEncoder), ), ) conn.commit() @@ -785,7 +785,7 @@ def approve_data(resource_id: str, file_name: str): data=MetadataAudit( dataset_id=sample_data.get("trait_name"), editor=sample_data.get("author"), - json_data=json.dumps(sample_data), + json_data=json.dumps(sample_data, cls=CustomJSONEncoder), ), ) # Once data is approved, rename it! -- cgit v1.2.3