Files
json/examples/parse_error.cpp
T
2026-10-26 21:24:35 +00:00

21 lines
460 B
C++

#include <iostream>
#include <nlohmann/json.hpp>
using nlohmann::json;
int main()
{
try
{
// parsing input with a syntax error
json j = json::parse("[1,2,3,]");
}
catch (const json::parse_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'
<< "exception id: " << e.id << '\n'
<< "byte position of error: " << e.byte << '\n';
}
}