https://blog.csdn.net/lintax/article/details/51549345
int str_to_cJSON(char *json_string, char *str_val) { char * out=NULL; cJSON *root=cJSON_CreateObject(); if (!root) { printf("Error before: [%s]\n",cJSON_GetErrorPtr()); return -1; } else { cJSON *item=cJSON_CreateString("Brett"); cJSON_AddItemToObject(root,"firstName",item); out=cJSON_Print(root); printf("out2:%s\n",out); cJSON_Delete(root); if(out!=NULL) { free(out); } } return 0; }