From c289e74e4ab8f3ae79a624787da3dd3904d689bc Mon Sep 17 00:00:00 2001 From: "jokob.sk" Date: Sun, 16 Oct 2022 16:57:46 +1100 Subject: [PATCH] attempt at byte string to string fix when generating json --- back/pialert.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/back/pialert.py b/back/pialert.py index 9aa679af..61c2201d 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1632,7 +1632,7 @@ def send_webhook (_json, _html): } # DEBUG - Write the json payload into a log file for debugging - write_file (LOG_PATH + '/webhook_payload.json', str(_json_payload)) + write_file (LOG_PATH + '/webhook_payload.json', json.dumps(_json_payload)) # Using the Slack-Compatible Webhook endpoint for Discord so that the same payload can be used for both if(WEBHOOK_URL.startswith('https://discord.com/api/webhooks/') and not WEBHOOK_URL.endswith("/slack")): @@ -1798,6 +1798,10 @@ def print_log (pText): def add_json_list (row, list): new_row = [] for column in row : + # if variable is of type bytes, convert to string + if isinstance(column, bytes): + column = column.decode('utf-8') + new_row.append(column) list.append(new_row)