sharandac / My-TTGO-Watch

A GUI named hedge for smartwatch like devices based on ESP32. Currently support for T-Watch2020 (V1,V2,V3), T-Watch2021, M5Paper, M5Core2 and native Linux support for testing.
GNU General Public License v2.0
537 stars 246 forks source link

I am performing a deserialization operation, but serialization failed #394

Closed Hans-Wu-cn closed 1 year ago

Hans-Wu-cn commented 1 year ago
/*
         * check if msg a json before add it to msg queue
         */
        BluetoothJsonRequest request(receivedData.c_str(), strlen(receivedData.c_str()) * 4);
        if (!request.isValid())
        {
            request.clear();
            return;
        }
        request.clear();
        SpiRamJsonDocument doc(strlen(receivedData.c_str()) * 4);
        log_i("data:%s", receivedData.c_str()); //[I][bleclt.cpp:133] notifyCallback(): data:{"board":"A205","type":"0"}
        // Parsing JSON strings
        DeserializationError error = deserializeJson(doc, receivedData.c_str());
        bluetooth_message_queue_msg("{\"t\":\"notify\",\"id\":1575479849,\"src\":\"Hangouts\",\"title\":\"\",\"body\":\"A203\"}");
        //check Parsing JSON strings is success
        if (error)
        {
            log_i("deserializeJson() failed: %s", error.c_str());
            receivedData = "";
            return;
        }

The console will print:[E][bluejsonrequest.h:35] BluetoothJsonRequest(): deserializeJson() failed: InvalidInput json data:{"board":"A205","type":"0"}