Closed weshouman closed 3 years ago
Hi @weshouman,
Indeed this library, StreamUtils, only works with streams. Your program doesn't use streams but strings.
If you want to see the content of the string, simply call Serial.print()
:
String text = extractContent(*filename);
Serial.println(text);
DeserializationError error = deserializeJson(ds, text);
BTW, as a best practice, I recommend that you let deserializeJson()
read from the File
directly.
See JsonConfigFile.ino for an example.
Lastly, if for some reason, you absolutely need to build a ReadLoggingStream
on top of a String
, you need to create a StringStream
first:
StringStream stream = extractContent(*filename);
ReadLoggingStream loggingStream(stream, Serial);
DeserializationError error = deserializeJson(ds, loggingStream);
Best regards, Benoit
Thanks a lot ^_^
When trying to follow this example to log a string while deserializing it I get either of the following errors (when using either a
String
orchar *
input)error: no matching function for call to 'StreamUtils::ReadLoggingStream::ReadLoggingStream(String&, HardwareSerial&)
error: no matching function for call to 'StreamUtils::ReadLoggingStream::ReadLoggingStream(char*&, HardwareSerial&)
Sample code