mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
📝 update documentation
This commit is contained in:
22
doc/examples/diagnostics_extended.cpp
Normal file
22
doc/examples/diagnostics_extended.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#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';
|
||||
}
|
||||
}
|
1
doc/examples/diagnostics_extended.link
Normal file
1
doc/examples/diagnostics_extended.link
Normal file
@ -0,0 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/pbz3ULoJ4maRnV8N"><b>online</b></a>
|
1
doc/examples/diagnostics_extended.output
Normal file
1
doc/examples/diagnostics_extended.output
Normal file
@ -0,0 +1 @@
|
||||
[json.exception.type_error.302] (/address/housenumber) type must be number, but is string
|
20
doc/examples/diagnostics_standard.cpp
Normal file
20
doc/examples/diagnostics_standard.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#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';
|
||||
}
|
||||
}
|
1
doc/examples/diagnostics_standard.link
Normal file
1
doc/examples/diagnostics_standard.link
Normal file
@ -0,0 +1 @@
|
||||
<a target="_blank" href="https://wandbox.org/permlink/fWfQhHzG03P6PAcC"><b>online</b></a>
|
1
doc/examples/diagnostics_standard.output
Normal file
1
doc/examples/diagnostics_standard.output
Normal file
@ -0,0 +1 @@
|
||||
[json.exception.type_error.302] type must be number, but is string
|
Reference in New Issue
Block a user