1 #include <iostream> 2 #include <nlohmann/json.hpp> 3 4 using json = nlohmann::json; 5 main()6int main() 7 { 8 try 9 { 10 // calling push_back() on a string value 11 json j = "string"; 12 j.push_back("another string"); 13 } 14 catch (json::type_error& e) 15 { 16 // output exception information 17 std::cout << "message: " << e.what() << '\n' 18 << "exception id: " << e.id << std::endl; 19 } 20 } 21