If there is no builtin method to convert the string, it would need the brackets and double quotes added.
My thoughts are that this could then more easily be read and sent on (just needs to be published to an MQTT topic) by other serial devices. e.g. an ESP with Tasmota.
The emonTx single-phase sketches are not mine. I suggested to Trystan that he should simplify the emonTx CM sketch because the complication added to try to force it to behave exactly like emonLibDS appeared to be creating problems.
Which there isn’t, to my knowledge…
The easy way is to use the pre-processor directives. The big advantage of those is the unwanted parts don’t compile and thus don’t carry a memory usage cost nor a run-time processing cost.
#define JSON at the top of the sketch (assuming you want JSON output, don’t if you don’t), and surround the pertinent Serial.print statements thus:
I’d still like to see it and as we are giving more options to use the serial output send it by Wi-Fi (ESP/Pico/PiZW) it would make things much easier to implement.
I’d suggest an option in the setup menu and then it can be changed easily. All it then needs is some additional characters added into the output string if the option is set.