mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-21 14:32:23 +02:00
Added JsonArray::createNestedObject()
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "JsonArray.h"
|
||||
|
||||
#include "JsonObject.h"
|
||||
#include "JsonValue.h"
|
||||
|
||||
JsonValue JsonArray::operator[](int index) const
|
||||
@ -49,7 +50,7 @@ void JsonArray::add(long value)
|
||||
addChild(node);
|
||||
}
|
||||
|
||||
void JsonArray::add(JsonContainer& innerContainer)
|
||||
void JsonArray::add(JsonContainer innerContainer)
|
||||
{
|
||||
JsonNode* node = createNode(JSON_PROXY);
|
||||
if (!node) return;
|
||||
@ -60,13 +61,23 @@ void JsonArray::add(JsonContainer& innerContainer)
|
||||
|
||||
JsonArray JsonArray::createNestedArray()
|
||||
{
|
||||
JsonNode* node = createNode(JSON_ARRAY);
|
||||
|
||||
if (node)
|
||||
{
|
||||
node->content.asContainer.buffer = _node->content.asContainer.buffer;
|
||||
addChild(node);
|
||||
}
|
||||
|
||||
JsonNode* node = createNestedContainer(JSON_ARRAY);
|
||||
return JsonArray(node);
|
||||
}
|
||||
|
||||
JsonObject JsonArray::createNestedObject()
|
||||
{
|
||||
JsonNode* node = createNestedContainer(JSON_OBJECT);
|
||||
return JsonObject(node);
|
||||
}
|
||||
|
||||
JsonNode* JsonArray::createNestedContainer(JsonNodeType type)
|
||||
{
|
||||
JsonNode* node = createNode(type);
|
||||
if (!node) return 0;
|
||||
|
||||
node->content.asContainer.buffer = _node->content.asContainer.buffer;
|
||||
addChild(node);
|
||||
|
||||
return node;
|
||||
}
|
@ -21,8 +21,12 @@ public:
|
||||
void add(double value, int decimals=2);
|
||||
void add(int value) { add((long) value); }
|
||||
void add(long value);
|
||||
void add(JsonContainer& innerContainer);
|
||||
|
||||
void add(JsonContainer nestedArray);
|
||||
|
||||
JsonArray createNestedArray();
|
||||
JsonObject createNestedObject();
|
||||
|
||||
private:
|
||||
JsonNode* createNestedContainer(JsonNodeType type);
|
||||
};
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "Internals/JsonNode.h"
|
||||
#include "Internals/IndentedPrint.h"
|
||||
|
||||
struct JsonNode;
|
||||
class JsonValue;
|
||||
class JsonArray;
|
||||
class JsonObject;
|
||||
class JsonValue;
|
||||
|
||||
class JsonContainer : public Printable
|
||||
{
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
#include "JsonContainer.h"
|
||||
|
||||
class JsonArray;
|
||||
class JsonValue;
|
||||
struct JsonNode;
|
||||
|
||||
class JsonObject : public JsonContainer
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user