I have a data logger that records time, status & temperature by appending to a file. (The logger is called from a cron job.)
It would be great if I could read the data into a web page script as JSON, but I don’t see a good way to do it — either my logger is more complicated, or my reader is more complicated.
My data is lines like:
[ timestamp, "status", temperature ]
[ 123456789, "sync", 12345]
I can add commas to the line ends easily enough, but either way, it’s not well-formatted JSON — you need brackets around the whole thing.
So either my logger must detect an empty data file and add a leading bracket, plus seek to the end, back up a character, replace the last close-bracket with a comma, and then append its own record with an extra closing bracket, or the reader has to massage the pre-JSON by slicing off a trailing comma and adding brackets around.
Is there an easier way to do this?