Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2022 18:40
What would you like to do?
static JsonObject toJson(const byte *payload, const uint32_t length) {
char *json = (char *)malloc(length);
memcpy(json, payload, length);
if (json[0] == NULL) {
json = json + 2;
json[length - 1] = NULL;
StaticJsonDocument<256> doc;
DeserializationError error = deserializeJson(doc, json);
if (error) {
return JsonObject();
} else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment