Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
See ArduinoJson memory usage and speed with string deduplication
#include <ArduinoJson.h>
void setup() {
Serial.begin(9600);
while (!Serial) continue;
StaticJsonDocument<516> doc;
const char* json = R"({"list":[{"temperature":21.2,"humidity":68.9,"weather":"overcast clouds"},{"temperature":19.7,"humidity":62.1,"weather":"clear sky"},{"temperature":18.6,"humidity":59.8,"weather":"clear sky"}]})";
unsigned long start = micros();
DeserializationError error = deserializeJson(doc, json);
unsigned long stop = micros();
// Test if parsing succeeds.
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
return;
}
Serial.print("doc.memoryUsage() = ");
Serial.println(doc.memoryUsage());
Serial.print("duration = ");
Serial.print(stop-start);
Serial.println("µs");
}
void loop() {
// not used in this example
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.