📝 fixing documentation #867
The example in the documentation on how to "force" an array of arrays was wrong since the first release. Fixed the documentation and added checks for the README unit tests.
This commit is contained in:
parent
0693945230
commit
772bb3cc20
3 changed files with 15 additions and 8 deletions
|
@ -160,7 +160,7 @@ json empty_object_implicit = json({});
|
|||
json empty_object_explicit = json::object();
|
||||
|
||||
// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]]
|
||||
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
|
||||
json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} });
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -100,13 +100,20 @@ TEST_CASE("README", "[hide]")
|
|||
{
|
||||
// ways to express the empty array []
|
||||
json empty_array_implicit = {{}};
|
||||
CHECK(empty_array_implicit.is_array());
|
||||
json empty_array_explicit = json::array();
|
||||
CHECK(empty_array_explicit.is_array());
|
||||
|
||||
// a way to express the empty object {}
|
||||
json empty_object_explicit = json::object();
|
||||
CHECK(empty_object_explicit.is_object());
|
||||
|
||||
// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]]
|
||||
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
|
||||
json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} });
|
||||
CHECK(array_not_object.is_array());
|
||||
CHECK(array_not_object.size() == 2);
|
||||
CHECK(array_not_object[0].is_array());
|
||||
CHECK(array_not_object[1].is_array());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue