mirror of
https://github.com/nlohmann/json.git
synced 2025-07-31 10:24:23 +03:00
📝 overworked documentation
Replacing references to std exceptions with user-defined exceptions. Also changed some examples to the new exceptions.
This commit is contained in:
BIN
doc/examples/at__object_t_key_type
Executable file
BIN
doc/examples/at__object_t_key_type
Executable file
Binary file not shown.
@ -26,8 +26,8 @@ int main()
|
||||
{
|
||||
object.at("the fast") = "il rapido";
|
||||
}
|
||||
catch (std::out_of_range& e)
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/tb5CaFfsMWpAvi7m"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/WtZ49NXtkzcLAx37"><b>online</b></a>
|
@ -1,3 +1,3 @@
|
||||
"il brutto"
|
||||
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
|
||||
out of range: key 'the fast' not found
|
||||
[json.exception.out_of_range.403] key 'the fast' not found
|
||||
|
3
doc/examples/at__object_t_key_type.test
Normal file
3
doc/examples/at__object_t_key_type.test
Normal file
@ -0,0 +1,3 @@
|
||||
"il brutto"
|
||||
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
|
||||
[json.exception.out_of_range.403] key 'the fast' not found
|
@ -20,7 +20,7 @@ int main()
|
||||
{
|
||||
std::cout << object.at("the fast") << '\n';
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
catch (json::out_of_range)
|
||||
{
|
||||
std::cout << "out of range" << '\n';
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/NFG86H5khRUePc1s"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/AsC3grSJ7UngjKwF"><b>online</b></a>
|
@ -21,8 +21,8 @@ int main()
|
||||
{
|
||||
array.at(5) = "sixth";
|
||||
}
|
||||
catch (std::out_of_range& e)
|
||||
catch (json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/R7z2SB2rMdFQ9XtR"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/EU0DspVPybW5cJDH"><b>online</b></a>
|
@ -1,3 +1,3 @@
|
||||
"third"
|
||||
["first","second","third","fourth"]
|
||||
out of range: array index 5 is out of range
|
||||
[json.exception.out_of_range.401] array index 5 is out of range
|
||||
|
@ -15,7 +15,7 @@ int main()
|
||||
{
|
||||
std::cout << array.at(5) << '\n';
|
||||
}
|
||||
catch (std::out_of_range)
|
||||
catch (json::out_of_range)
|
||||
{
|
||||
std::cout << "out of range" << '\n';
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/L1bMeiN6nYm7JrvA"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/ZiPo8P49B2Cc8B85"><b>online</b></a>
|
BIN
doc/examples/get_ref
Executable file
BIN
doc/examples/get_ref
Executable file
Binary file not shown.
@ -19,7 +19,7 @@ int main()
|
||||
{
|
||||
auto r3 = value.get_ref<json::number_float_t&>();
|
||||
}
|
||||
catch (std::domain_error& ex)
|
||||
catch (json::type_error& ex)
|
||||
{
|
||||
std::cout << ex.what() << '\n';
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/WiO1oBWDvIs82OX1"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/lsl8Ex3d3SOYnKHu"><b>online</b></a>
|
@ -1,2 +1,2 @@
|
||||
17 17
|
||||
incompatible ReferenceType for get_ref, actual type is number
|
||||
[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
|
||||
|
2
doc/examples/get_ref.test
Normal file
2
doc/examples/get_ref.test
Normal file
@ -0,0 +1,2 @@
|
||||
17 17
|
||||
[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
|
BIN
doc/examples/json_pointer
Executable file
BIN
doc/examples/json_pointer
Executable file
Binary file not shown.
@ -19,9 +19,9 @@ int main()
|
||||
{
|
||||
json::json_pointer p9("foo");
|
||||
}
|
||||
catch (std::domain_error& e)
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << "domain_error: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// error: JSON pointer uses escape symbol ~ not followed by 0 or 1
|
||||
@ -29,9 +29,9 @@ int main()
|
||||
{
|
||||
json::json_pointer p10("/foo/~");
|
||||
}
|
||||
catch (std::domain_error& e)
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << "domain_error: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
|
||||
// error: JSON pointer uses escape symbol ~ not followed by 0 or 1
|
||||
@ -39,8 +39,8 @@ int main()
|
||||
{
|
||||
json::json_pointer p11("/foo/~3");
|
||||
}
|
||||
catch (std::domain_error& e)
|
||||
catch (json::parse_error& e)
|
||||
{
|
||||
std::cout << "domain_error: " << e.what() << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/WM2WWKnXdmdw17Wu"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/Wlvqfd3JpEXTv2iH"><b>online</b></a>
|
@ -1,3 +1,3 @@
|
||||
domain_error: JSON pointer must be empty or begin with '/'
|
||||
domain_error: escape error: '~' must be followed with '0' or '1'
|
||||
domain_error: escape error: '~' must be followed with '0' or '1'
|
||||
[json.exception.parse_error.107] parse error at 1: JSON pointer must be empty or begin with '/' - was: 'foo'
|
||||
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
||||
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
||||
|
3
doc/examples/json_pointer.test
Normal file
3
doc/examples/json_pointer.test
Normal file
@ -0,0 +1,3 @@
|
||||
[json.exception.parse_error.107] parse error at 1: JSON pointer must be empty or begin with '/' - was: 'foo'
|
||||
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
||||
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
|
Reference in New Issue
Block a user