You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a json encoded configuration file on ESP8266 filesystem (SPIFFS) which I can quickly parse the information that i need like this:
bool loadConfiguration() {
File configFile = SPIFFS.open("/auth/config.json", "r");
if (!configFile) {
Serial.println(F("[ WARN ] Failed to open config file"));
return false;
}
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
// We don't use String here because ArduinoJson library requires the input
// buffer to be mutable. If you don't use ArduinoJson, you may as well
// use configFile.readString instead.
configFile.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer;
JsonObject& json = jsonBuffer.parseObject(buf.get());
if (!json.success()) {
Serial.println(F("[ WARN ] Failed to parse config file"));
return false;
}
}
What I want to do is changing a field on parsed file for example "devicename":"esp-rfid" and write it back as a whole without breaking other fields.
Should I simply get the all the fields on memory, change the field that i want to change and create another buffer and create another JsonObject and print it to the file?
I'm already doing above, because i'm not aware of any other approach. Anyway, kind regards.
The text was updated successfully, but these errors were encountered:
omersiar
changed the title
[Question] Is there any simple approach to update a field parsed object and print back?
[Question] Is there any simple approach to update a field on parsed object and print back?
Jul 11, 2017
Hello, thanks for the great library, it really helped with my project. https://github.com/omersiar/esp-rfid
I have a json encoded configuration file on ESP8266 filesystem (SPIFFS) which I can quickly parse the information that i need like this:
What I want to do is changing a field on parsed file for example
"devicename":"esp-rfid"
and write it back as a whole without breaking other fields.Should I simply get the all the fields on memory, change the field that i want to change and create another buffer and create another JsonObject and print it to the file?
I'm already doing above, because i'm not aware of any other approach. Anyway, kind regards.
The text was updated successfully, but these errors were encountered: