Files
ArduinoJson/src/JsonArray.cpp

41 lines
936 B
C++
Raw Normal View History

// Copyright Benoit Blanchon 2014-2016
2014-10-23 23:39:22 +02:00
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
2014-10-23 23:39:22 +02:00
2014-11-03 18:35:22 +01:00
#include "../include/ArduinoJson/JsonArray.hpp"
2014-10-29 14:24:34 +01:00
2014-11-03 18:35:22 +01:00
#include "../include/ArduinoJson/JsonBuffer.hpp"
#include "../include/ArduinoJson/JsonObject.hpp"
2014-10-16 16:25:42 +02:00
2014-10-18 23:05:54 +02:00
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
2014-10-30 14:03:33 +01:00
JsonArray JsonArray::_invalid(NULL);
JsonArray::node_type *JsonArray::getNodeAt(size_t index) const {
node_type *node = _firstNode;
while (node && index--) node = node->next;
return node;
2014-10-29 14:24:34 +01:00
}
void JsonArray::removeAt(size_t index) { removeNode(getNodeAt(index)); }
void JsonArray::writeTo(JsonWriter &writer) const {
writer.beginArray();
2014-10-29 14:24:34 +01:00
const node_type *child = _firstNode;
while (child) {
child->content.writeTo(writer);
2014-10-29 14:24:34 +01:00
child = child->next;
if (!child) break;
2014-10-29 14:24:34 +01:00
writer.writeComma();
2014-10-29 14:24:34 +01:00
}
writer.endArray();
2014-10-29 14:24:34 +01:00
}