mirror of
https://github.com/nlohmann/json.git
synced 2024-11-30 18:59:02 +08:00
23 lines
378 B
C++
23 lines
378 B
C++
#include <iostream>
|
|
|
|
# define JSON_DIAGNOSTICS 1
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
json j;
|
|
j["address"]["street"] = "Fake Street";
|
|
j["address"]["housenumber"] = "12";
|
|
|
|
try
|
|
{
|
|
int housenumber = j["address"]["housenumber"];
|
|
}
|
|
catch (json::exception& e)
|
|
{
|
|
std::cout << e.what() << '\n';
|
|
}
|
|
}
|