json/doc/examples/type_error.cpp
2017-08-29 23:46:26 +02:00

21 lines
418 B
C++

#include <iostream>
#include "json.hpp"
using json = nlohmann::json;
int main()
{
try
{
// calling push_back() on a string value
json j = "string";
j.push_back("another string");
}
catch (json::type_error& e)
{
// output exception information
std::cout << "message: " << e.what() << '\n'
<< "exception id: " << e.id << std::endl;
}
}