Open bcatalin opened 7 years ago
Hi bcatalin, Declare the JsonParser object and set the listener object too locally and it will parse json objects recursively(check bellow). I have managed to debug the problem and i found that if comes from the if statement where it checks the "state" variable and it won't complete the next object parsing since the last state was STATE_DONE -1 which then the parse method returns.
if(SPIFFS.exists("/unsent.json")) { JsonStreamingParser parser; parser.setListener(&listener); Serial.println(F("I have unsent data")); File unsentFile = SPIFFS.open("/unsent.json","r"); if(unsentFile) { Serial.printf("unsent.json size:%d",unsentFile.size()); Serial.println(""); while(unsentFile.available()) { String line = unsentFile.readStringUntil('\n'); Serial.println(line); char parse_line[200]; line.toCharArray(parse_line, 200); for (int i = 0; i < sizeof( parse_line ); i++) { parser.parse(parse_line[i]); } } } }
Hi Daniel,
I have an issue with the stream parser. I am trying to parse each line from a file in SPIFFS and is only working for the first line.