Cjson print problem

toxicjv
Posts: 1
Joined: Mon Dec 13, 2021 7:53 pm

Cjson print problem

Postby toxicjv » Mon Dec 13, 2021 7:59 pm

IDF version 3.4 release
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

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: Cjson print problem

Postby AgentSmithers » Tue Jan 18, 2022 11:12 pm

I'm here, would you mind posting the Debug Crash data. I am not big on the ESP32IDF but I have alot of play time with the 8266. Post the feedback here and I'll take a look and see what I can find out for you. I do have a install of ESP32 here laying around I can copy your code on my end this week and see if I can reproduce the issue as well.

Who is online

Users browsing this forum: No registered users and 186 guests