Viewing and editing .jsonl files #206
-
New to the project so please excuse my question! Is there a reason openHASP uses .jsonl files that are not valid json in their own right? I assume this is becuase it it more effieient to process on the ESP for rendering. I am finding it frustrating when building up the config for a plate that whitespace/line breaks cant be included. Ideally I would like my files in a "pretty printed" format with an array of objects where each object is an elemnt to render (a line in the current format) For me this would be much easier to read files in VSCode etc. I am using Home Assistant to push the jsonl to the plates so was considering creating the files in a more readable and using a git hook or gitub action to create the requried jsonl files. What do others do here? Am I missing something obvious? Having looked at the code HA component I had also thought about modifying the component to accept .json files in the format described above as well as .jsonl. This way the rendering loop could iterate over the array or lines in a file as it does now. Would you consider a PR like this? I appreciate this may not be ideal as files in this format could not be stored on the device and used. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I think this could be acceptable as long as it doesn't break original functionality (eg. to parse unmodified files, in original format too). You could perhaps use a different extension for your new file format to avoid confusion. |
Beta Was this translation helpful? Give feedback.
-
JSON lines is meant to keep the processing overhead on the ESP as minimal as possible. It should be easy to convert from a big JSON object/array to JSON lines on a PC instead of doing that on the MCU side. |
Beta Was this translation helpful? Give feedback.
-
I'm in favour! specially if we can validate the JSON before sending :) |
Beta Was this translation helpful? Give feedback.
JSON lines is meant to keep the processing overhead on the ESP as minimal as possible.
It can parse a line as soon as the
\n
is encountered instead of parsing the whole complex JSON object/array in memory first.This allows streaming a large file or MQTT buffer without creating much overhead or duplicating values...
It should be easy to convert from a big JSON object/array to JSON lines on a PC instead of doing that on the MCU side.