我有一个JSON数据,我想在C++中写入JSON文件。我在用
nlohmann json
下面是代码:
using nlohmann::json;
std::ofstream output_file("C:\\Program Files (x86)\\output.json");
json outJson;
std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::string created(30, '\0');
std::strftime(&created[0], created.size(), "%Y-%m-%d %H:%M:%S", std::localtime(&now));
outJson["Created"] = created;
outJson["DataId"] = "T-452";
outJson["Type"] = "UserData";
output_file << outJson;
但没有任何东西能被拯救
output.json
.