cJSON object to string将json对象转换成字符串
c - Converting cjson json to string
try cJSON_PrintUnformatted. cJSON_Print will print with whitespace for formatting. If you want to print without formatting, use cJSON_PrintUnformatted.
cJSON_Print will give you "{\n\t\"type1\":\t\"car\",\n\t\"type2\":\t\"bus\"\n}"
Referenced from:https://stackoverflow.com/questions/56073560/converting-cjson-json-to-string
cJSON_Print会得到这样的结果:
"{\n\t\"type1\":\t\"car\",\n\t\"type2\":\t\"bus\"\n}"
cJSON_PrintUnformatted会得到如下结果
"{\"type1\":\"car\",\"type2\":\"bus\"}"
注意,要使用cJSON_free释放字符串指针。
本文链接地址:https://const.net.cn/185.html