rapidjson
rapidjson copied to clipboard
rapidjson 解析含数字(如"18615.")字符串时出错
您好! 当我使用rapidjson解析: 字符串 {"data":[[18615.,"aaa",30.]],"total":0} 时出错? 其中数字(18615.)是其他由json库(如fastjson)返回的.
代码如下: const char json[] = "{"data":[[18615.,"aaa",30.]],"total":0}"; Document document; char buffer[sizeof(json)]; memcpy(buffer, json, sizeof(json)); if (document.ParseInsitu(buffer).HasParseError()) { cout << "Failed to parse json string: " << jobj.GetParseError() << endl; return 1; }
打印结果:
Failed to parse json string: 14
14的含义: kParseErrorNumberMissFraction
请问对字符串中含有小数点的数字怎么处理呢? 谢谢!
这是不合语法的 JSON,应该要那个生成的库去 debug。
小数点后面应该有数字吧。