-
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Hi all
JsonObject& GetJsonRoot() {
File lConfigFile = SPIFFS.open(CONFIG_FILE_PATH, "r");
DynamicJsonBuffer lJsonBuffer;
JsonObject* lJsonRoot = NULL;
if (!lConfigFile) {
Serial.println("Failed to open config file");
return *lJsonRoot;
}
size_t lFileSize = lConfigFile.size(); std::unique_ptr<char[]> lFileData(new char[lFileSize]); lConfigFile.readBytes(lFileData.get(), lFileSize); lConfigFile.close(); lJsonRoot = &lJsonBuffer.parseObject(lFileData.get()); if (!lJsonRoot->success()) { Serial.println("Failed to parse config file"); return *lJsonRoot; } lJsonRoot->printTo(Serial); return *lJsonRoot;
}
Actually when i print lJsonRoot just at the end of GetJsonRoot,it is giving correct data.
But when i print the in the caller method it is giving garbage data for only first name of data.
Correct Data:-{"serverName":"api.example.com","accessToken":"128du9as8du12eoue8da98h123ueh9h98"}
Incorrect Data:- {"⸮�":"api.example.com","accessToken":"128du9as8du12eoue8da98h123ueh9h98"}
Thanks in advance for the help.
Kind Regards
Pulkit Jain