我正在使用来自 https://github.com/nlohmann/json 的库
我需要将我的 JSON 写入文件,但我在文档中找不到任何相关内容。
谁能帮忙?
最佳答案
您可以像这样将 JSON 值 j
写入文件:
std::ofstream o("output.json");
o << j << std::endl;
如果你想美化输出,使用:
std::ofstream o("pretty.json");
o << std::setw(4) << j << std::endl;
关于C++ - 如何将 JSON 写回文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40029100/