jsoncpp转字符串
时间: 2023-09-18 18:14:39 浏览: 129
可以使用 `Json::FastWriter` 类将 `Json::Value` 对象转换为字符串。示例代码如下:
```c++
#include <iostream>
#include <jsoncpp/json/json.h>
int main() {
Json::Value root;
root["name"] = "John";
root["age"] = 30;
root["city"] = "New York";
Json::FastWriter writer;
std::string jsonString = writer.write(root);
std::cout << jsonString << std::endl;
return 0;
}
```
输出结果为:
```json
{"name":"John","age":30,"city":"New York"}
```
阅读全文
相关推荐









