📝 more documentation for the new exceptions
This commit is contained in:
parent
fe71e7df1f
commit
1ab580d6e9
15 changed files with 269 additions and 230 deletions
|
@ -59,6 +59,8 @@ doxygen: create_output create_links
|
|||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer>@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
$(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html
|
||||
|
||||
upload: clean doxygen check_output
|
||||
cd html ; ../scripts/git-update-ghpages nlohmann/json
|
||||
|
|
|
@ -15,8 +15,8 @@ int main()
|
|||
{
|
||||
std::cout << array.at(5) << '\n';
|
||||
}
|
||||
catch (json::out_of_range)
|
||||
catch (const json::out_of_range& e)
|
||||
{
|
||||
std::cout << "out of range" << '\n';
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/ZiPo8P49B2Cc8B85"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/L70DHUpUzdDQtLgZ"><b>online</b></a>
|
|
@ -1,2 +1,2 @@
|
|||
"third"
|
||||
out of range
|
||||
[json.exception.out_of_range.401] array index 5 is out of range
|
||||
|
|
|
@ -18,4 +18,14 @@ int main()
|
|||
std::cout << j_array_range << '\n';
|
||||
std::cout << j_number_range << '\n';
|
||||
std::cout << j_object_range << '\n';
|
||||
|
||||
// example for an exception
|
||||
try
|
||||
{
|
||||
json j_invalid(j_number.begin() + 1, j_number.end());
|
||||
}
|
||||
catch (json::invalid_iterator& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/nKF1QcieoCHm6Lez"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/oUU2X0pbZq7gawRB"><b>online</b></a>
|
|
@ -1,3 +1,4 @@
|
|||
["bravo","charly"]
|
||||
42
|
||||
{"one":"eins"}
|
||||
[json.exception.invalid_iterator.204] iterators out of range
|
||||
|
|
|
@ -8,10 +8,20 @@ int main()
|
|||
json j_no_init_list = json::object();
|
||||
json j_empty_init_list = json::object({});
|
||||
json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
|
||||
//json j_invalid_list = json::object({ "one", 1 }); // would throw
|
||||
|
||||
// serialize the JSON objects
|
||||
std::cout << j_no_init_list << '\n';
|
||||
std::cout << j_empty_init_list << '\n';
|
||||
std::cout << j_list_of_pairs << '\n';
|
||||
|
||||
// example for an exception
|
||||
try
|
||||
{
|
||||
// can only create an object from a list of pairs
|
||||
json j_invalid_object = json::object({{ "one", 1, 2 }});
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/hhxRaUctq3FA54SW"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/Ub9U5AMbng3oZiao"><b>online</b></a>
|
|
@ -1,3 +1,4 @@
|
|||
{}
|
||||
{}
|
||||
{"one":1,"two":2}
|
||||
[json.exception.type_error.301] cannot create object from initializer list
|
||||
|
|
|
@ -46,4 +46,14 @@ int main()
|
|||
{
|
||||
std::cout << i.first << ": " << i.second << '\n';
|
||||
}
|
||||
|
||||
// example for an exception
|
||||
try
|
||||
{
|
||||
bool v1 = json_types["string"];
|
||||
}
|
||||
catch (json::type_error& e)
|
||||
{
|
||||
std::cout << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a target="_blank" href="http://melpon.org/wandbox/permlink/rUGX6AaVuZfwiiYI"><b>online</b></a>
|
||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/drFSKFXJd8IMzMK3"><b>online</b></a>
|
|
@ -9,3 +9,4 @@ number: {"floating-point":17.23,"integer":42}
|
|||
null: null
|
||||
boolean: true
|
||||
array: [1,2,3,4,5]
|
||||
[json.exception.type_error.302] type must be boolean, but is string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue