Closed BlackEdder closed 7 years ago
I have worked out that this (probably) is because outBuf starts with a '\0'. Is there anyway to make arduinojson encode the whole character array (including '\0'), for example by giving it the length of the buffer to copy?
Hello Edwin,
I'm not sure I understand what you're trying to accomplish. Are you trying to put binary data (possibly containing zeros) into a JSON string? If so, why don't you use base-64 encoding?
Regards
If so, why don't you use base-64 encoding?
Short answer, because I didn't know that was a standard way of doing it. Longer answer, because base64 encoding takes at least 1.5 times as many characters as the base256 encoding I was trying to accomplish :)
Base-64 is the usual way to store binary data in JSON.
I'm afraid there is nothing I can do. Can we close this issue?
Yes, thank you for the feedback :)
As part of our mesh library we use ArduinoJson for all messaging. This works very well for most of the messages, but there is one message type where json is just to inefficient (space wise), so I am trying to optimise that by serialising and deserialising the data, before adding it to the json message. This works fine, until I convert the resulting JsonObject to a string and then decode it again. Doing that seems to change the data. See below for a minimal example (the problematic case is at the bottom). Any help/pointers would be appreciated.
Some further details: