编译时遇到的错误:
error: convert from 'long int' to 'const Json::Value' is ambiguous
value["timestamp"] = getCurrentTime();
^
解决办法:
// getCurrentTime()返回的数据类型为 long
// 想要解决上面的那个问题,可以先将 long 转换为 Json::Int64
// 再将转换完成的数据传给 value["timestamp"] 即可
Json::Int64 tmstp = getCurrentTime();
value["timestamp"] = tmstp;
本文解决了从long整型到Json::Value类型转换时出现的编译错误问题。通过将long类型的数据先转换为Json::Int64类型,再将其赋值给Json对象的方法,有效地避免了类型转换歧义。
2913

被折叠的 条评论
为什么被折叠?



