#include <ArduinoJson.h>
#include "TypeOf.h"
#include "LinkedList.h"
String json = "{\"var0\": 64,\"var1\": 521,\"var2\": 123.456,\"var3\": \"Good morning Vietnam\",\"var4\": \"Hello World.\",\"var5\": false}";
char var0;
int var1;
float var2;
String var3;
char var4[16];
bool var5;
void setup() {
Serial.begin(115200);
// Init the variables linked list object
VariableList list;
list.addItem(var0, "var0");
list.addItem(var1, "var1");
list.addItem(var2, "var2");
list.addItem(var3, "var3");
list.addItem(var4, "var4");
list.addItem(var5, "var5");
// Create ArduinoJson object from string (will be a file)
DynamicJsonDocument doc(512);
deserializeJson(doc, json);
Serial.println("Start values:");
serializeJsonPretty(doc, Serial);
// Init variable values loading from json
list.loadValues(doc);
// Edit the content of some variables
var1 = -999;
var3 = "This is a new String";
strcpy(var4, "HELLO WORLD !!!");
var5 = true;
// Save current values to a new ArduinoJson object (will be a file)
Serial.println("\n\nCurrent values:");
list.saveValues();
}
void loop() {
// put your main code here, to run repeatedly:
}