cJSON * root=NULL;
Char * out=NULL;
Root=cJSON_CreateObject ();
If (NULL==root) printf (" cJSON_CreateObject err \ n ");
CJSON_AddNumberToObject (root, "type", 2);
CJSON_AddNumberToObject (root, "errorCode", code);
CJSON_AddStringToObject (root, "STR", "STR");
Out=cJSON_Print (root);
If (NULL==out) printf (" cJSON_Print err ");
CJSON_Delete (root);
SendToUart ((unsigned char *) out, strlen (out));
Send: printf (" % s \ n ", out);
Free (out);


CodePudding user response:
CJson libraries may not achieve cJSON_AddNumberToObject (source code is not found in the function), you can firstCJSON * cJSON_CreateNumber (double num) data object, then the
cJSON_AddItemToObjec
CodePudding user response:
Thank you for your reply, although the problem not solve, I tried, is also not