Comments (3)
I've used it in this project: click
Quick untested example:
#include <JSONtoSPIFFS.h>
#define CONFIGFILE "config.json"
JSONtoSPIFFS Config;
// Define some variables
bool setting1;
int setting2;
String setting3;
void setup() {
Serial.begin(115200);
// init library
SPIFFS.begin();
Config.begin(&SPIFFS);
// set variables
setting1 = false;
setting2 = 343;
setting3 = "hello world";
// save config
if (Config.loadConfigFile(CONFIGFILE)) { // this will also create the configfile if it doesn't exists
Config.setValue("mySetting1", setting1); // returns true on success
Config.setValue("mySetting2", setting2);
Config.setValue("mySetting3", setting3);
Config.saveConfigFile(); // Commit changes
}
// change variables
setting1 = true;
setting2 = 100;
setting3 = "no hello world";
// load config
if (Config.loadConfigFile(CONFIGFILE)) {
Config.getValue("mySetting1", setting1);
Config.getValue("mySetting2", setting2);
Config.getValue("mySetting3", setting3);
Config.closeConfigFile(); // dont forget to close the file!
}
// check variables
Serial.println(setting1);
Serial.println(setting2);
Serial.println(setting3);
// Remove "mySetting1"
if (Config.loadConfigFile(CONFIGFILE)) {
Config.removeKey("mySetting1");
Config.saveConfigFile(); // Commit changes
}
// Delete configfile
Config.deleteConfigFile(CONFIGFILE); // file has to be closed!
}
Not that ALL methods return true on success and false when failed!
Also have a look at JSONtoSPIFFS.h
to enable Debug-Logging.
from jsontospiffs.
If I have the following json:
{ "Debug": true, "Device": [ { "Serial": "AUT010001" } ], }
How to update the Serial field?
from jsontospiffs.
afaik nested json data is not supported. Can you modify this to:
{ "Debug": true, "Device": "", "Serial": "AUT010001"}
from jsontospiffs.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsontospiffs.