Fixed JsonVariant::success() which didn't propagate JsonArray::success() nor JsonObject::success() (issue #342).

This commit is contained in:
Benoit Blanchon
2016-08-29 20:54:39 +02:00
parent e401498e4a
commit ffb9b6d1ba
6 changed files with 87 additions and 24 deletions

View File

@@ -8,11 +8,29 @@
#pragma once
#include "JsonArray.hpp"
#include "JsonObject.hpp"
#include "JsonArraySubscript.hpp"
#include "JsonObject.hpp"
namespace ArduinoJson {
inline JsonVariant::JsonVariant(JsonArray &array) {
if (array.success()) {
_type = Internals::JSON_ARRAY;
_content.asArray = &array;
} else {
_type = Internals::JSON_UNDEFINED;
}
}
inline JsonVariant::JsonVariant(JsonObject &object) {
if (object.success()) {
_type = Internals::JSON_OBJECT;
_content.asObject = &object;
} else {
_type = Internals::JSON_UNDEFINED;
}
}
template <>
inline bool JsonArray::setNodeValue(node_type *node, String &value) {
const char *copy = _buffer->strdup(value);