mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-08-02 02:14:30 +02:00
Handle parsing invalid json string
This commit is contained in:
@@ -354,16 +354,16 @@ bool Configuration::begin(void) {
|
|||||||
* @return false Failure
|
* @return false Failure
|
||||||
*/
|
*/
|
||||||
bool Configuration::parse(String data, bool isLocal) {
|
bool Configuration::parse(String data, bool isLocal) {
|
||||||
logInfo("Parse configure: " + data);
|
logInfo("Parsing configuration: " + data);
|
||||||
|
|
||||||
JSONVar root = JSON.parse(data);
|
JSONVar root = JSON.parse(data);
|
||||||
failedMessage = "";
|
failedMessage = "";
|
||||||
if (root == undefined) {
|
if (root == undefined || JSONVar::typeof_(root) != "object") {
|
||||||
|
logError("Parse configuration failed, JSON invalid (" + JSONVar::typeof_(root) + ")");
|
||||||
failedMessage = "JSON invalid";
|
failedMessage = "JSON invalid";
|
||||||
logError(failedMessage);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logInfo("Parse configure success");
|
logInfo("Parse configuration success");
|
||||||
|
|
||||||
/** Is configuration changed */
|
/** Is configuration changed */
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
Reference in New Issue
Block a user