From f71ffd510ad62c084c986f8689dad14abdcce58c Mon Sep 17 00:00:00 2001 From: fvanroie Date: Wed, 25 Nov 2020 17:02:42 +0100 Subject: [PATCH] Allow string, object and array json commands --- src/hasp_dispatch.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp index 71e2f0d0..a92a1a4d 100644 --- a/src/hasp_dispatch.cpp +++ b/src/hasp_dispatch.cpp @@ -501,7 +501,7 @@ void dispatchParseJson(const char * payload) // json.shrinkToFit(); if(jsonError) { // Couldn't parse incoming JSON command - Log.warning(TAG_MSGR, F("JSON: Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); + Log.warning(TAG_MSGR, F("Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); } else { if(json.is()) { @@ -514,9 +514,17 @@ void dispatchParseJson(const char * payload) // handle json as a jsonl uint8_t savedPage = haspGetPage(); hasp_new_object(json.as(), savedPage); - } else { + } else if(json.is()) { // handle json as a single command dispatchTextLine(json.as()); + } else if(json.is()) { + // handle json as a single command + dispatchTextLine(json.as()); + } else if(json.is()) { + // handle json as a single command + dispatchTextLine(json.as().c_str()); + } else { + Log.warning(TAG_MSGR, F("Failed to parse incoming JSON command")); } } }