Rev | Line | |
---|
[209] | 1 | // Copyright Benoit Blanchon 2014-2016
|
---|
| 2 | // MIT License
|
---|
| 3 | //
|
---|
| 4 | // Arduino JSON library
|
---|
| 5 | // https://github.com/bblanchon/ArduinoJson
|
---|
| 6 | // If you like this project, please add a star!
|
---|
| 7 |
|
---|
| 8 | #include "../include/ArduinoJson/JsonObject.hpp"
|
---|
| 9 |
|
---|
| 10 | #include <string.h> // for strcmp
|
---|
| 11 |
|
---|
| 12 | #include "../include/ArduinoJson/Internals/StaticStringBuilder.hpp"
|
---|
| 13 | #include "../include/ArduinoJson/JsonArray.hpp"
|
---|
| 14 | #include "../include/ArduinoJson/JsonBuffer.hpp"
|
---|
| 15 |
|
---|
| 16 | using namespace ArduinoJson;
|
---|
| 17 | using namespace ArduinoJson::Internals;
|
---|
| 18 |
|
---|
| 19 | JsonObject JsonObject::_invalid(NULL);
|
---|
| 20 |
|
---|
| 21 | JsonObject::node_type *JsonObject::getNodeAt(const char *key) const {
|
---|
| 22 | for (node_type *node = _firstNode; node; node = node->next) {
|
---|
| 23 | if (!strcmp(node->content.key, key)) return node;
|
---|
| 24 | }
|
---|
| 25 | return NULL;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | void JsonObject::writeTo(JsonWriter &writer) const {
|
---|
| 29 | writer.beginObject();
|
---|
| 30 |
|
---|
| 31 | const node_type *node = _firstNode;
|
---|
| 32 | while (node) {
|
---|
| 33 | writer.writeString(node->content.key);
|
---|
| 34 | writer.writeColon();
|
---|
| 35 | node->content.value.writeTo(writer);
|
---|
| 36 |
|
---|
| 37 | node = node->next;
|
---|
| 38 | if (!node) break;
|
---|
| 39 |
|
---|
| 40 | writer.writeComma();
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | writer.endObject();
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.