Hello
I am writing a example file and my goal is to save some measurement into a jsonl file
Example:
{"mod":"demo","date":"24-07-05","sensors":[{"temp":"22","altitude":"454"}]}
{"mod":"demo","date":"24-07-06","sensors":[{"temp":"23","altitude":"454"}]}
{"mod":"demo","date":"24-07-07","sensors":[{"temp":"24","altitude":"454"}]}
{"mod":"demo","date":"24-07-08","sensors":[{"temp":"23","altitude":"454"}]}
selon JSON Line, each
{"mod":"demo","date":"24-07-05","sensors":[{"temp":"22","altitude":"454"}]}
must be on one line. So at the end of the entry, we need to have a \n
If we look at my script here,
- I open the file
- I serialized my object and I save the string directly into my file. I followed that example (See "write to a file")
- Then I close my file.
If now I look at my file, each entry follow the previous entry. All is in one line.
File sd_log;
sd_log = sd.open(fileName, O_RDWR | O_CREAT | O_AT_END); // Open the file log.jsonl
serializeJson(jdoc,sd_log); // serialize and write te directly to the file
sd_log.close();
My question, is there a way to tell serializejson() to append a \n ?
Thanks