diff --git a/.travis.yml b/.travis.yml index a41c078a..f7e7ec9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,6 @@ install: - ( cd ${ARDUINO_ESP8266_ROOT}/tools && python get.py ) before_script: - mkdir -p ${ARDUINO_HOME}/libraries -- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.1.1 ArduinoJson ) +- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.2 ArduinoJson ) script: - ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino diff --git a/src/Firebase.h b/src/Firebase.h index b0f00895..c5a11263 100644 --- a/src/Firebase.h +++ b/src/Firebase.h @@ -26,7 +26,7 @@ // TODO(edcoyne): move this into our mock_arduino fork where we actually do the // override. #define ARDUINO_STRING_OVERRIDE -#include "third-party/arduino-json-5.1.1/include/ArduinoJson.h" +#include "third-party/arduino-json-5.2/include/ArduinoJson.h" class FirebaseGet; class FirebaseSet; diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.ipp b/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.ipp deleted file mode 100644 index c9fb3b71..00000000 --- a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.ipp +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright Benoit Blanchon 2014-2016 -// MIT License -// -// Arduino JSON library -// https://github.com/bblanchon/ArduinoJson -// If you like this project, please add a star! - -#pragma once - -#include "Configuration.hpp" -#include "JsonVariant.hpp" -#include "Internals/Parse.hpp" - -#include - -namespace ArduinoJson { - -inline JsonVariant::JsonVariant(bool value) { - using namespace Internals; - _type = JSON_BOOLEAN; - _content.asInteger = static_cast(value); -} - -inline JsonVariant::JsonVariant(const char *value) { - _type = Internals::JSON_STRING; - _content.asString = value; -} - -inline JsonVariant::JsonVariant(Internals::Unparsed value) { - _type = Internals::JSON_UNPARSED; - _content.asString = value; -} - -inline JsonVariant::JsonVariant(JsonArray &array) { - _type = Internals::JSON_ARRAY; - _content.asArray = &array; -} - -inline JsonVariant::JsonVariant(JsonObject &object) { - _type = Internals::JSON_OBJECT; - _content.asObject = &object; -} - -template -inline T JsonVariant::invalid() { - return T(); -} - -template -inline bool JsonVariant::is() const { - return false; -} - -template <> // in .cpp -bool JsonVariant::is() const; - -template <> // in .cpp -bool JsonVariant::is() const; - -template <> // int .cpp -bool JsonVariant::is() const; - -template <> -inline bool JsonVariant::is() const { - return _type == Internals::JSON_STRING; -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return _type == Internals::JSON_ARRAY; -} - -template <> -inline bool JsonVariant::is() const { - return _type == Internals::JSON_ARRAY; -} - -template <> -inline bool JsonVariant::is() const { - return _type == Internals::JSON_OBJECT; -} - -template <> -inline bool JsonVariant::is() const { - return _type == Internals::JSON_OBJECT; -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -template <> -inline bool JsonVariant::is() const { - return is(); -} - -inline Internals::JsonInteger JsonVariant::asInteger() const { - if (_type == Internals::JSON_INTEGER || _type == Internals::JSON_BOOLEAN) - return _content.asInteger; - - if (_type >= Internals::JSON_FLOAT_0_DECIMALS) - return static_cast(_content.asFloat); - - if ((_type == Internals::JSON_STRING || _type == Internals::JSON_UNPARSED) && - _content.asString) { - if (!strcmp("true", _content.asString)) return 1; - return Internals::parse(_content.asString); - } - - return 0L; -} - -#if ARDUINOJSON_ENABLE_STD_STREAM -inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) { - return source.printTo(os); -} -#endif - -} // namespace ArduinoJson diff --git a/src/third-party/arduino-json-5.1.1/CHANGELOG.md b/src/third-party/arduino-json-5.2/CHANGELOG.md similarity index 92% rename from src/third-party/arduino-json-5.1.1/CHANGELOG.md rename to src/third-party/arduino-json-5.2/CHANGELOG.md index 7ea8888c..9bf3495d 100644 --- a/src/third-party/arduino-json-5.1.1/CHANGELOG.md +++ b/src/third-party/arduino-json-5.2/CHANGELOG.md @@ -1,6 +1,14 @@ ArduinoJson: change log ======================= +v5.2.0 +------ + +* Added `JsonVariant::as()` as a synonym for `JsonVariant::as()` (issue #257) +* Added example `JsonHttpClient` (issue #256) +* Added `JsonArray::copyTo()` and `JsonArray::copyFrom()` (issue #254) +* Added `RawJson()` to insert pregenerated JSON portions (issue #259) + v5.1.1 ------ diff --git a/src/third-party/arduino-json-5.1.1/LICENSE.md b/src/third-party/arduino-json-5.2/LICENSE.md similarity index 100% rename from src/third-party/arduino-json-5.1.1/LICENSE.md rename to src/third-party/arduino-json-5.2/LICENSE.md diff --git a/src/third-party/arduino-json-5.1.1/README.md b/src/third-party/arduino-json-5.2/README.md similarity index 91% rename from src/third-party/arduino-json-5.1.1/README.md rename to src/third-party/arduino-json-5.2/README.md index 6a560077..ae1d7c4a 100644 --- a/src/third-party/arduino-json-5.1.1/README.md +++ b/src/third-party/arduino-json-5.2/README.md @@ -15,7 +15,8 @@ Features * JSON decoding (comments are supported) * JSON encoding (with optional indentation) * Elegant API, very easy to use -* Efficient (no malloc, nor copy) +* Fixed memory allocation (zero malloc) +* No data duplication (zero copy) * Portable (written in C++98) * Self-contained (no external dependency) * Small footprint @@ -91,19 +92,19 @@ From StackOverflow user `thegreendroid`: > It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality. From GitHub user `zacsketches`: - > Thanks for a great library!!! > I've been watching you consistently develop this library over the past six months, and I used it today for a publish and subscribe architecture designed to help hobbyists move into more advanced robotics. Your library allowed me to implement remote subscription in order to facilitate multi-processor robots. > ArduinoJson saved me a week's worth of time!! [From Reddit user `erm_what_`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusjk8c): - > This is a great library and I wouldn't be able to do the project I'm doing without it. I completely recommend it. [From Reddit user `makerhacks`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusqg7b): - > I am just starting an ESP8266 clock project and now I can output JSON from my server script and interpret it painlessly. +[From Twitter user `@hemalchevli`](https://twitter.com/hemalchevli/status/715788439397011456): +> ArduinoJson library should be used as a benchmark/reference for making libraries. Truly elegant. + Donators -------- @@ -116,6 +117,7 @@ Special thanks to the following persons and companies who made generous donation * A B Doodkorte * Scott Smith * Johann Stieger +* Gustavo Donizeti Gini --- diff --git a/src/third-party/arduino-json-5.1.1/examples/IndentedPrintExample/IndentedPrintExample.ino b/src/third-party/arduino-json-5.2/examples/IndentedPrintExample/IndentedPrintExample.ino similarity index 100% rename from src/third-party/arduino-json-5.1.1/examples/IndentedPrintExample/IndentedPrintExample.ino rename to src/third-party/arduino-json-5.2/examples/IndentedPrintExample/IndentedPrintExample.ino diff --git a/src/third-party/arduino-json-5.1.1/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/src/third-party/arduino-json-5.2/examples/JsonGeneratorExample/JsonGeneratorExample.ino similarity index 100% rename from src/third-party/arduino-json-5.1.1/examples/JsonGeneratorExample/JsonGeneratorExample.ino rename to src/third-party/arduino-json-5.2/examples/JsonGeneratorExample/JsonGeneratorExample.ino diff --git a/src/third-party/arduino-json-5.2/examples/JsonHttpClient/JsonHttpClient.ino b/src/third-party/arduino-json-5.2/examples/JsonHttpClient/JsonHttpClient.ino new file mode 100644 index 00000000..6bb3175d --- /dev/null +++ b/src/third-party/arduino-json-5.2/examples/JsonHttpClient/JsonHttpClient.ino @@ -0,0 +1,195 @@ +// Sample Arduino Json Web Client +// Downloads and parse http://jsonplaceholder.typicode.com/users/1 +// +// Copyright Benoit Blanchon 2014-2016 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson +// If you like this project, please add a star! + +#include +#include +#include + +EthernetClient client; + +const char* server = "jsonplaceholder.typicode.com"; // server's address +const char* resource = "/users/1"; // http resource +const unsigned long BAUD_RATE = 9600; // serial connection speed +const unsigned long HTTP_TIMEOUT = 10000; // max respone time from server +const size_t MAX_CONTENT_SIZE = 512; // max size of the HTTP response + +// The type of data that we want to extract from the page +struct UserData { + char name[32]; + char company[32]; +}; + +// ARDUINO entry point #1: runs once when you press reset or power the board +void setup() { + initSerial(); + initEthernet(); +} + +// ARDUINO entry point #2: runs over and over again forever +void loop() { + if (connect(server)) { + if (sendRequest(server, resource) && skipResponseHeaders()) { + char response[MAX_CONTENT_SIZE]; + readReponseContent(response, sizeof(response)); + + UserData userData; + if (parseUserData(response, &userData)) { + printUserData(&userData); + } + } + disconnect(); + } + wait(); +} + +// Initialize Serial port +void initSerial() { + Serial.begin(BAUD_RATE); + while (!Serial) { + ; // wait for serial port to initialize + } + Serial.println("Serial ready"); +} + +// Initialize Ethernet library +void initEthernet() { + byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; + if (!Ethernet.begin(mac)) { + Serial.println("Failed to configure Ethernet"); + return; + } + Serial.println("Ethernet ready"); + delay(1000); +} + +// Open connection to the HTTP server +bool connect(const char* hostName) { + Serial.print("Connect to "); + Serial.println(hostName); + + bool ok = client.connect(hostName, 80); + + Serial.println(ok ? "Connected" : "Connection Failed!"); + return ok; +} + +// Send the HTTP GET request to the server +bool sendRequest(const char* host, const char* resource) { + Serial.print("GET "); + Serial.println(resource); + + client.print("GET "); + client.print(resource); + client.println(" HTTP/1.1"); + client.print("Host: "); + client.println(server); + client.println("Connection: close"); + client.println(); + + return true; +} + +// Skip HTTP headers so that we are at the beginning of the response's body +bool skipResponseHeaders() { + // HTTP headers end with an empty line + char endOfHeaders[] = "\r\n\r\n"; + + client.setTimeout(HTTP_TIMEOUT); + bool ok = client.find(endOfHeaders); + + if (!ok) { + Serial.println("No response or invalid response!"); + } + + return ok; +} + +// Read the body of the response from the HTTP server +void readReponseContent(char* content, size_t maxSize) { + size_t length = client.readBytes(content, maxSize); + content[length] = 0; + Serial.println(content); +} + +// Parse the JSON from the input string and extract the interesting values +// Here is the JSON we need to parse +// { +// "id": 1, +// "name": "Leanne Graham", +// "username": "Bret", +// "email": "Sincere@april.biz", +// "address": { +// "street": "Kulas Light", +// "suite": "Apt. 556", +// "city": "Gwenborough", +// "zipcode": "92998-3874", +// "geo": { +// "lat": "-37.3159", +// "lng": "81.1496" +// } +// }, +// "phone": "1-770-736-8031 x56442", +// "website": "hildegard.org", +// "company": { +// "name": "Romaguera-Crona", +// "catchPhrase": "Multi-layered client-server neural-net", +// "bs": "harness real-time e-markets" +// } +// } +bool parseUserData(char* content, struct UserData* userData) { + // Compute optimal size of the JSON buffer according to what we need to parse. + // This is only required if you use StaticJsonBuffer. + const size_t BUFFER_SIZE = + JSON_OBJECT_SIZE(8) // the root object has 8 elements + + JSON_OBJECT_SIZE(5) // the "address" object has 5 elements + + JSON_OBJECT_SIZE(2) // the "geo" object has 2 elements + + JSON_OBJECT_SIZE(3); // the "company" object has 3 elements + + // Allocate a temporary memory pool on the stack + StaticJsonBuffer jsonBuffer; + // If the memory pool is too big for the stack, use this instead: + // DynamicJsonBuffer jsonBuffer; + + JsonObject& root = jsonBuffer.parseObject(content); + + if (!root.success()) { + Serial.println("JSON parsing failed!"); + return false; + } + + // Here were copy the strings we're interested in + strcpy(userData->name, root["name"]); + strcpy(userData->company, root["company"]["name"]); + // It's not mandatory to make a copy, you could just use the pointers + // Since, they are pointing inside the "content" buffer, so you need to make + // sure it's still in memory when you read the string + + return true; +} + +// Print the data extracted from the JSON +void printUserData(const struct UserData* userData) { + Serial.print("Name = "); + Serial.println(userData->name); + Serial.print("Company = "); + Serial.println(userData->company); +} + +// Close the connection with the HTTP server +void disconnect() { + Serial.println("Disconnect"); + client.stop(); +} + +// Pause for a 1 minute +void wait() { + Serial.println("Wait 60 seconds"); + delay(60000); +} diff --git a/src/third-party/arduino-json-5.1.1/examples/JsonParserExample/JsonParserExample.ino b/src/third-party/arduino-json-5.2/examples/JsonParserExample/JsonParserExample.ino similarity index 100% rename from src/third-party/arduino-json-5.1.1/examples/JsonParserExample/JsonParserExample.ino rename to src/third-party/arduino-json-5.2/examples/JsonParserExample/JsonParserExample.ino diff --git a/src/third-party/arduino-json-5.1.1/examples/JsonServer/JsonServer.ino b/src/third-party/arduino-json-5.2/examples/JsonServer/JsonServer.ino similarity index 100% rename from src/third-party/arduino-json-5.1.1/examples/JsonServer/JsonServer.ino rename to src/third-party/arduino-json-5.2/examples/JsonServer/JsonServer.ino diff --git a/src/third-party/arduino-json-5.1.1/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/src/third-party/arduino-json-5.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino similarity index 100% rename from src/third-party/arduino-json-5.1.1/examples/JsonUdpBeacon/JsonUdpBeacon.ino rename to src/third-party/arduino-json-5.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson.h b/src/third-party/arduino-json-5.2/include/ArduinoJson.h similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson.h rename to src/third-party/arduino-json-5.2/include/ArduinoJson.h diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Arduino/Print.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/Print.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Arduino/Print.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/Print.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Arduino/String.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Arduino/String.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Configuration.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Configuration.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Configuration.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Configuration.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/DynamicJsonBuffer.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/DynamicJsonBuffer.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/DynamicJsonBuffer.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/DynamicJsonBuffer.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/BlockJsonBuffer.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/BlockJsonBuffer.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/BlockJsonBuffer.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/BlockJsonBuffer.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Comments.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Comments.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Comments.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Comments.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/DummyPrint.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/DummyPrint.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/DummyPrint.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/DummyPrint.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/DynamicStringBuilder.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/DynamicStringBuilder.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/DynamicStringBuilder.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/DynamicStringBuilder.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Encoding.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Encoding.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Encoding.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Encoding.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ForceInline.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ForceInline.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ForceInline.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ForceInline.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/IndentedPrint.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/IndentedPrint.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/IndentedPrint.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/IndentedPrint.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonBufferAllocated.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonBufferAllocated.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonBufferAllocated.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonBufferAllocated.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonFloat.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonFloat.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonFloat.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonFloat.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonInteger.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonInteger.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonInteger.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonInteger.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonParser.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonParser.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonParser.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonParser.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonPrintable.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonPrintable.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonPrintable.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonPrintable.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonVariantContent.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonVariantContent.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonVariantContent.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonVariantContent.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonVariantType.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonVariantType.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonVariantType.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonVariantType.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonWriter.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonWriter.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/JsonWriter.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/JsonWriter.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/List.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/List.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/List.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/List.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListConstIterator.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListConstIterator.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListConstIterator.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListConstIterator.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListIterator.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListIterator.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListIterator.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListIterator.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListNode.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListNode.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ListNode.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ListNode.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Parse.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Parse.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Parse.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Parse.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Prettyfier.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Prettyfier.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Prettyfier.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/Prettyfier.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ReferenceType.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ReferenceType.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/ReferenceType.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/ReferenceType.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/StaticStringBuilder.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/StaticStringBuilder.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/StaticStringBuilder.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/StaticStringBuilder.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/StreamPrintAdapter.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/StreamPrintAdapter.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/StreamPrintAdapter.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/Internals/StreamPrintAdapter.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArray.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArray.hpp similarity index 80% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArray.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArray.hpp index d478ab52..5d01ad75 100644 --- a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArray.hpp +++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArray.hpp @@ -161,6 +161,59 @@ class JsonArray : public Internals::JsonPrintable, // Serialize the array to the specified JsonWriter. void writeTo(Internals::JsonWriter &writer) const; + // Imports a 1D array + template + bool copyFrom(T(&array)[N]) { + return copyFrom(array, N); + } + + // Imports a 1D array + template + bool copyFrom(T *array, size_t len) { + bool ok = true; + for (size_t i = 0; i < len; i++) { + ok &= add(array[i]); + } + return ok; + } + + // Imports a 2D array + template + bool copyFrom(T(&array)[N1][N2]) { + bool ok = true; + for (size_t i = 0; i < N1; i++) { + JsonArray &nestedArray = createNestedArray(); + for (size_t j = 0; j < N2; j++) { + ok &= nestedArray.add(array[i][j]); + } + } + return ok; + } + + // Exports a 1D array + template + size_t copyTo(T(&array)[N]) const { + return copyTo(array, N); + } + + // Exports a 1D array + template + size_t copyTo(T *array, size_t len) const { + size_t i = 0; + for (const_iterator it = begin(); it != end() && i < len; ++it) + array[i++] = *it; + return i; + } + + // Exports a 2D array + template + void copyTo(T(&array)[N1][N2]) const { + size_t i = 0; + for (const_iterator it = begin(); it != end() && i < N1; ++it) { + it->asArray().copyTo(array[i++]); + } + } + private: node_type *getNodeAt(size_t index) const; diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArray.ipp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArray.ipp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArray.ipp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArray.ipp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArraySubscript.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArraySubscript.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonArraySubscript.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonArraySubscript.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonBuffer.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonBuffer.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonBuffer.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonBuffer.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObject.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObject.hpp similarity index 96% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObject.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObject.hpp index 9f4a061f..758e21c0 100644 --- a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObject.hpp +++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObject.hpp @@ -71,6 +71,7 @@ class JsonObject : public Internals::JsonPrintable, // bool set(TKey key, float value); // bool set(TKey key, double value); // bool set(TKey key, const char* value); + // bool set(TKey key, RawJson value); template FORCE_INLINE bool set( JsonObjectKey key, T value, diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObject.ipp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObject.ipp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObject.ipp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObject.ipp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObjectKey.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObjectKey.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObjectKey.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObjectKey.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObjectSubscript.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObjectSubscript.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonObjectSubscript.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonObjectSubscript.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonPair.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonPair.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonPair.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonPair.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.hpp similarity index 71% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.hpp index f570c96f..8b056803 100644 --- a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariant.hpp +++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.hpp @@ -13,8 +13,8 @@ #include "Internals/JsonPrintable.hpp" #include "Internals/JsonVariantContent.hpp" #include "Internals/JsonVariantType.hpp" -#include "Internals/Unparsed.hpp" #include "JsonVariantBase.hpp" +#include "RawJson.hpp" #include "TypeTraits/EnableIf.hpp" #include "TypeTraits/IsFloatingPoint.hpp" #include "TypeTraits/IsIntegral.hpp" @@ -80,7 +80,7 @@ class JsonVariant : public JsonVariantBase { FORCE_INLINE JsonVariant(const char *value); // Create a JsonVariant containing an unparsed string - FORCE_INLINE JsonVariant(Internals::Unparsed value); + FORCE_INLINE JsonVariant(RawJson value); // Create a JsonVariant containing a reference to an array. FORCE_INLINE JsonVariant(JsonArray &array); @@ -89,6 +89,7 @@ class JsonVariant : public JsonVariantBase { FORCE_INLINE JsonVariant(JsonObject &object); // Get the variant as the specified type. + // // short as() const; // int as() const; // long as() const; @@ -97,6 +98,7 @@ class JsonVariant : public JsonVariantBase { as() const { return static_cast(asInteger()); } + // // double as() const; // float as() const; template @@ -105,6 +107,7 @@ class JsonVariant : public JsonVariantBase { as() const { return static_cast(asFloat()); } + // // const String as() const; template const typename TypeTraits::EnableIf::value, @@ -112,14 +115,17 @@ class JsonVariant : public JsonVariantBase { as() const { return toString(); } + // // const char* as() const; // const char* as() const; template - typename TypeTraits::EnableIf::value, + typename TypeTraits::EnableIf::value || + TypeTraits::IsSame::value, const char *>::type as() const { return asString(); } + // // const bool as() const template const typename TypeTraits::EnableIf::value, @@ -127,6 +133,7 @@ class JsonVariant : public JsonVariantBase { as() const { return asInteger() != 0; } + // // JsonArray& as const; // JsonArray& as const; // JsonArray& as const; @@ -140,6 +147,7 @@ class JsonVariant : public JsonVariantBase { as() const { return asArray(); } + // // JsonObject& as const; // JsonObject& as const; // JsonObject& as const; @@ -156,8 +164,71 @@ class JsonVariant : public JsonVariantBase { // Tells weither the variant has the specified type. // Returns true if the variant has type type T, false otherwise. + // + // short as() const; + // int as() const; + // long as() const; + template + const typename TypeTraits::EnableIf::value, + bool>::type + is() const { + return isInteger(); + } + // + // double is() const; + // float is() const; + template + const typename TypeTraits::EnableIf::value, + bool>::type + is() const { + return isFloat(); + } + // + // const bool is() const template - bool is() const; + const typename TypeTraits::EnableIf::value, + bool>::type + is() const { + return isBoolean(); + } + // + // bool is() const; + // bool is() const; + template + typename TypeTraits::EnableIf::value || + TypeTraits::IsSame::value, + bool>::type + is() const { + return isString(); + } + // + // bool is const; + // bool is const; + // bool is const; + template + typename TypeTraits::EnableIf< + TypeTraits::IsSame< + typename TypeTraits::RemoveConst< + typename TypeTraits::RemoveReference::type>::type, + JsonArray>::value, + bool>::type + is() const { + return isArray(); + } + // + // JsonObject& as const; + // JsonObject& as const; + // JsonObject& as const; + template + typename TypeTraits::EnableIf< + TypeTraits::IsSame< + typename TypeTraits::RemoveConst< + typename TypeTraits::RemoveReference::type>::type, + JsonObject>::value, + bool>::type + is() const { + return isObject(); + } // Serialize the variant to a JsonWriter void writeTo(Internals::JsonWriter &writer) const; @@ -174,6 +245,12 @@ class JsonVariant : public JsonVariantBase { String toString() const; Internals::JsonFloat asFloat() const; Internals::JsonInteger asInteger() const; + bool isBoolean() const; + bool isFloat() const; + bool isInteger() const; + bool isArray() const { return _type == Internals::JSON_ARRAY; } + bool isObject() const { return _type == Internals::JSON_OBJECT; } + bool isString() const { return _type == Internals::JSON_STRING; } // The current type of the variant Internals::JsonVariantType _type; @@ -198,6 +275,7 @@ struct JsonVariant::IsConstructibleFrom { TypeTraits::IsSame::value || TypeTraits::IsSame::value || TypeTraits::IsSame::value || + TypeTraits::IsSame::value || TypeTraits::IsSame::value || TypeTraits::IsSame::value || TypeTraits::IsSame::value || diff --git a/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.ipp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.ipp new file mode 100644 index 00000000..b47b9219 --- /dev/null +++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariant.ipp @@ -0,0 +1,71 @@ +// Copyright Benoit Blanchon 2014-2016 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson +// If you like this project, please add a star! + +#pragma once + +#include "Configuration.hpp" +#include "JsonVariant.hpp" +#include "Internals/Parse.hpp" + +#include + +namespace ArduinoJson { + +inline JsonVariant::JsonVariant(bool value) { + using namespace Internals; + _type = JSON_BOOLEAN; + _content.asInteger = static_cast(value); +} + +inline JsonVariant::JsonVariant(const char *value) { + _type = Internals::JSON_STRING; + _content.asString = value; +} + +inline JsonVariant::JsonVariant(RawJson value) { + _type = Internals::JSON_UNPARSED; + _content.asString = value; +} + +inline JsonVariant::JsonVariant(JsonArray &array) { + _type = Internals::JSON_ARRAY; + _content.asArray = &array; +} + +inline JsonVariant::JsonVariant(JsonObject &object) { + _type = Internals::JSON_OBJECT; + _content.asObject = &object; +} + +template +inline T JsonVariant::invalid() { + return T(); +} + +inline Internals::JsonInteger JsonVariant::asInteger() const { + if (_type == Internals::JSON_INTEGER || _type == Internals::JSON_BOOLEAN) + return _content.asInteger; + + if (_type >= Internals::JSON_FLOAT_0_DECIMALS) + return static_cast(_content.asFloat); + + if ((_type == Internals::JSON_STRING || _type == Internals::JSON_UNPARSED) && + _content.asString) { + if (!strcmp("true", _content.asString)) return 1; + return Internals::parse(_content.asString); + } + + return 0L; +} + +#if ARDUINOJSON_ENABLE_STD_STREAM +inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) { + return source.printTo(os); +} +#endif + +} // namespace ArduinoJson diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariantBase.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariantBase.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/JsonVariantBase.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/JsonVariantBase.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Unparsed.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/RawJson.hpp similarity index 64% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Unparsed.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/RawJson.hpp index a01508b1..9b1f40dd 100644 --- a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/Internals/Unparsed.hpp +++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/RawJson.hpp @@ -8,14 +8,14 @@ #pragma once namespace ArduinoJson { -namespace Internals { -class Unparsed { + +// A special type of data that can be used to insert pregenerated JSON portions. +class RawJson { public: - explicit Unparsed(const char* str) : _str(str) {} + explicit RawJson(const char* str) : _str(str) {} operator const char*() const { return _str; } private: const char* _str; }; } -} diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/StaticJsonBuffer.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/StaticJsonBuffer.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/StaticJsonBuffer.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/StaticJsonBuffer.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/EnableIf.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/EnableIf.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/EnableIf.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/EnableIf.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsFloatingPoint.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsFloatingPoint.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsFloatingPoint.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsFloatingPoint.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsIntegral.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsIntegral.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsIntegral.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsIntegral.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsReference.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsReference.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsReference.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsReference.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsSame.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsSame.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/IsSame.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/IsSame.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/RemoveConst.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/RemoveConst.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/RemoveConst.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/RemoveConst.hpp diff --git a/src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/RemoveReference.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/RemoveReference.hpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/include/ArduinoJson/TypeTraits/RemoveReference.hpp rename to src/third-party/arduino-json-5.2/include/ArduinoJson/TypeTraits/RemoveReference.hpp diff --git a/src/third-party/arduino-json-5.1.1/keywords.txt b/src/third-party/arduino-json-5.2/keywords.txt similarity index 100% rename from src/third-party/arduino-json-5.1.1/keywords.txt rename to src/third-party/arduino-json-5.2/keywords.txt diff --git a/src/third-party/arduino-json-5.1.1/library.properties b/src/third-party/arduino-json-5.2/library.properties similarity index 93% rename from src/third-party/arduino-json-5.1.1/library.properties rename to src/third-party/arduino-json-5.2/library.properties index 5b0ae67b..906901be 100644 --- a/src/third-party/arduino-json-5.1.1/library.properties +++ b/src/third-party/arduino-json-5.2/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=5.1.1 +version=5.2.0 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=An efficient and elegant JSON library for Arduino. diff --git a/src/third-party/arduino-json-5.1.1/src/ArduinoJson.h b/src/third-party/arduino-json-5.2/src/ArduinoJson.h similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/ArduinoJson.h rename to src/third-party/arduino-json-5.2/src/ArduinoJson.h diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/Comments.cpp b/src/third-party/arduino-json-5.2/src/Internals/Comments.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/Comments.cpp rename to src/third-party/arduino-json-5.2/src/Internals/Comments.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/Encoding.cpp b/src/third-party/arduino-json-5.2/src/Internals/Encoding.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/Encoding.cpp rename to src/third-party/arduino-json-5.2/src/Internals/Encoding.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/IndentedPrint.cpp b/src/third-party/arduino-json-5.2/src/Internals/IndentedPrint.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/IndentedPrint.cpp rename to src/third-party/arduino-json-5.2/src/Internals/IndentedPrint.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/JsonParser.cpp b/src/third-party/arduino-json-5.2/src/Internals/JsonParser.cpp similarity index 95% rename from src/third-party/arduino-json-5.1.1/src/Internals/JsonParser.cpp rename to src/third-party/arduino-json-5.2/src/Internals/JsonParser.cpp index beb68092..ebea9aa9 100644 --- a/src/third-party/arduino-json-5.1.1/src/Internals/JsonParser.cpp +++ b/src/third-party/arduino-json-5.2/src/Internals/JsonParser.cpp @@ -195,7 +195,7 @@ bool JsonParser::parseStringTo(JsonVariant *destination) { if (hasQuotes) { *destination = value; } else { - *destination = Unparsed(value); + *destination = RawJson(value); } return true; } diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/List.cpp b/src/third-party/arduino-json-5.2/src/Internals/List.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/List.cpp rename to src/third-party/arduino-json-5.2/src/Internals/List.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/Prettyfier.cpp b/src/third-party/arduino-json-5.2/src/Internals/Prettyfier.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/Prettyfier.cpp rename to src/third-party/arduino-json-5.2/src/Internals/Prettyfier.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/Internals/StaticStringBuilder.cpp b/src/third-party/arduino-json-5.2/src/Internals/StaticStringBuilder.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/Internals/StaticStringBuilder.cpp rename to src/third-party/arduino-json-5.2/src/Internals/StaticStringBuilder.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/JsonArray.cpp b/src/third-party/arduino-json-5.2/src/JsonArray.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/JsonArray.cpp rename to src/third-party/arduino-json-5.2/src/JsonArray.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/JsonBuffer.cpp b/src/third-party/arduino-json-5.2/src/JsonBuffer.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/JsonBuffer.cpp rename to src/third-party/arduino-json-5.2/src/JsonBuffer.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/JsonObject.cpp b/src/third-party/arduino-json-5.2/src/JsonObject.cpp similarity index 100% rename from src/third-party/arduino-json-5.1.1/src/JsonObject.cpp rename to src/third-party/arduino-json-5.2/src/JsonObject.cpp diff --git a/src/third-party/arduino-json-5.1.1/src/JsonVariant.cpp b/src/third-party/arduino-json-5.2/src/JsonVariant.cpp similarity index 90% rename from src/third-party/arduino-json-5.1.1/src/JsonVariant.cpp rename to src/third-party/arduino-json-5.2/src/JsonVariant.cpp index d2bee252..0b524b85 100644 --- a/src/third-party/arduino-json-5.1.1/src/JsonVariant.cpp +++ b/src/third-party/arduino-json-5.2/src/JsonVariant.cpp @@ -47,8 +47,7 @@ String JsonVariant::toString() const { return s; } -template <> -bool JsonVariant::is() const { +bool JsonVariant::isBoolean() const { if (_type == JSON_BOOLEAN) return true; if (_type != JSON_UNPARSED || _content.asString == NULL) return false; @@ -57,8 +56,7 @@ bool JsonVariant::is() const { !strcmp(_content.asString, "false"); } -template <> -bool JsonVariant::is() const { +bool JsonVariant::isInteger() const { if (_type == JSON_INTEGER) return true; if (_type != JSON_UNPARSED || _content.asString == NULL) return false; @@ -70,8 +68,7 @@ bool JsonVariant::is() const { return *end == '\0' && errno == 0; } -template <> -bool JsonVariant::is() const { +bool JsonVariant::isFloat() const { if (_type >= JSON_FLOAT_0_DECIMALS) return true; if (_type != JSON_UNPARSED || _content.asString == NULL) return false; diff --git a/src/third-party/arduino-json-string-override.patch b/src/third-party/arduino-json-string-override.patch new file mode 100644 index 00000000..8d220d31 --- /dev/null +++ b/src/third-party/arduino-json-string-override.patch @@ -0,0 +1,16 @@ +diff --git a/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp b/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp +index a11a651..83cf650 100644 +--- a/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp ++++ b/src/third-party/arduino-json-5.2/include/ArduinoJson/Arduino/String.hpp +@@ -9,8 +9,11 @@ + + #ifndef ARDUINO + ++#ifndef ARDUINO_STRING_OVERRIDE ++#define ARDUINO_STRING_OVERRIDE + #include + typedef std::string String; ++#endif + + #else + diff --git a/test/modem/Makefile b/test/modem/Makefile index 88e8caa4..d796a4b4 100644 --- a/test/modem/Makefile +++ b/test/modem/Makefile @@ -123,7 +123,7 @@ arduino_mock_all.a : ArduinoMockAll.o $(AR) $(ARFLAGS) $@ $^ # Builds ArduinoJson -ARDUINO_JSON_SRC_ = ../../src/third-party/arduino-json-5.1.1/src +ARDUINO_JSON_SRC_ = ../../src/third-party/arduino-json-5.2/src JsonObject.o : $(ARDUINO_JSON_SRC_) $(CXX) $(CPPFLAGS) -I$(ARDUINO_JSON_SRC_) $(CXXFLAGS) -c \ $(ARDUINO_JSON_SRC_)/JsonObject.cpp