1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-07 18:02:57 +03:00
This commit is contained in:
nlohmann
2025-05-22 06:02:49 +00:00
parent 954dedad9d
commit c5cf12c0d5
253 changed files with 1012 additions and 736 deletions

View File

@@ -0,0 +1,37 @@
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::string s = R"(
{
"planets": [
"Mercury",
"Venus",
"Earth",
"Mars",
"Jupiter",
"Uranus",
"Neptune",
]
}
)";
try
{
json j = json::parse(s);
}
catch (json::exception& e)
{
std::cout << e.what() << std::endl;
}
json j = json::parse(s,
/* callback */ nullptr,
/* allow exceptions */ true,
/* ignore_comments */ false,
/* ignore_trailing_commas */ true);
std::cout << j.dump(2) << '\n';
}