我正在使用https://github.com/nlohmann/json
中的库
,我需要将 JSON 写入文件,但我在文档中找不到任何关于此的想法。
有人可以帮忙吗?
您可以将 JSON 值写入j文件,如下所示:
std::ofstream o("output.json");
o << j << std::endl;
Run Code Online (Sandbox Code Playgroud)
如果您希望美化输出,请使用:
std::ofstream o("pretty.json");
o << std::setw(4) << j << std::endl;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10889 次 |
| 最近记录: |