Qt中用cJSON解析带中文的QString

在使用cJSON解析存储在QString中的带有中文的JSON时,可以使用下面方法:

  • QString转换为cJSON可用的char*类型
cJSON *jsonRoot = cJSON_Parse(json.toLocal8Bit().data());
  • cJSON的输出也需要对应的转换
cJSON *tempJson = cJSON_GetObjectItem(jsonRoot, "result");
if(nullptr != tempJson)
	QString result = QString::fromLocal8Bit(tempJson->valuestring);
原文地址:https://www.cnblogs.com/kohlrabi/p/6823436.html