ESP8266 Developer Zone The Official ESP8266 Forum 2022-01-18T23:12:58+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=75271 2022-01-18T23:12:58+08:00 2022-01-18T23:12:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75271&p=100570#p100570 <![CDATA[Re: Cjson print problem]]> Statistics: Posted by AgentSmithers — Tue Jan 18, 2022 11:12 pm


]]>
2021-12-13T19:59:07+08:00 2021-12-13T19:59:07+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75271&p=100446#p100446 <![CDATA[Cjson print problem]]> ISSUE : using cJSON_AddNumberToObject crashes the ESP8266 during cJSON_Print command. The same piece of code executed correctly on ESP32.

void json_task(void *para)
{
int stackmem = uxTaskGetStackHighWaterMark(NULL);
ESP_LOGI("TAG", "stack space = %d", stackmem);

cJSON *root = cJSON_CreateObject();
bool res=cJSON_AddNumberToObject(root,"meta",212);
//cJSON_AddStringToObject(root,"meta","stringval");
char *out=cJSON_Print(root);
//cJSON_PrintPreallocated(root,resp,1500,true);
ESP_LOGI("TAG","\n%s\n",out);
while(1){vTaskDelay(100);}
}


the issue seems to be only with AddNumeberToObject, cJSON_AddStringToObject works fine.

Please help me debug the issue.
thanks

Statistics: Posted by toxicjv — Mon Dec 13, 2021 7:59 pm


]]>