我正在使用 C++ 读取 json 值
Json::Reader reader
并且该值存储在 Json::Value root
这个根包含“age”和“id”,我想将 root[“age”] 转换为 int。
我尝试使用 .str() 将其转换为字符串,但无法获得。
有什么建议吗?
原文由 rocx 发布,翻译遵循 CC BY-SA 4.0 许可协议
我正在使用 C++ 读取 json 值
Json::Reader reader
并且该值存储在 Json::Value root
这个根包含“age”和“id”,我想将 root[“age”] 转换为 int。
我尝试使用 .str() 将其转换为字符串,但无法获得。
有什么建议吗?
原文由 rocx 发布,翻译遵循 CC BY-SA 4.0 许可协议
3 回答1.1k 阅读✓ 已解决
1 回答995 阅读✓ 已解决
1 回答733 阅读✓ 已解决
4 回答785 阅读
1 回答862 阅读
1 回答893 阅读
1 回答662 阅读
在
jsoncpp
他们在Json::Value
对象上提供辅助方法。您只需调用asInt()
方法对值进行转换即可。