Open Muhan1995 opened 3 years ago
Could your please offer the parsing error msg? You can get it with CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
function
Here: cJSON *json_processing = cJSON_Parse(msg_json); Trace(1, "Infi error parse:"); Trace(1, cJSON_GetErrorPtr()); if(json_processing != NULL) { Trace(1,"Parse json ok"); ........................... } else { Trace(1,"Error parse json"); } cJSON_Delete(json_processing);
the function returns nothing
Screen:
Found the reason. The problem went away when the json was done this way: char* msg_json = "{ \"state\": { \"desired\": { \"EjectPowerBank\": \"3\" } } }"; So the problem really was in the standard library. I think that he could not parse int because of this it gave a NULL result. Now I'm fixing standard libraries. Then I'll tell you how it turned out to fix. Thanks everyone!!!
After such alterations, everything worked. The problem with the strtod () function was that it was not correctly implemented in the SDK. I replaced it with the atof () function.
After such alterations, everything worked. The problem with the strtod () function was that it was not correctly implemented in the SDK. I replaced it with the atof () function.
Oh my god! I solved the same problem using your method, thank you very much!
Hello! Thank you so much for your work! I have a JSON parse problem. It returns NULL what could be the problem ??? The rest cJSON_CreateObject (), cJSON_AddStringToObject (), cJSON_AddItemToObject (), cJSON_Print () all work wonderfully !!! Here is some of the code: cJSON_Hooks memoryHook; memoryHook.malloc_fn = OS_Malloc; memoryHook.free_fn = OS_Free; cJSON_InitHooks (& memoryHook);
cJSON json_processing = cJSON_Parse (msg_json); if (json_processing! = NULL) { cJSON state = cJSON_GetObjectItem (json_processing, "state"); cJSON * desired = cJSON_GetObjectItem (state, "desired"); if (desired! = NULL) { .............................. } } else { Trace (1, "Error parse json"); } cJSON_Delete (json_processing);
My module: Al-thinker A9G SDK: GPRS_C_SDK-master IDE: CSDTK42 could there be a problem in the standard std libraries ??? I heard something is wrong. Link: https://github.com/Ai-Thinker-Open/GPRS_C_SDK/tree/master/include/std_inc I tried to install fresh versions CJSON. But it doesn't help!