The example below shows how array elements can be read and written using []
operator. Note the addition of null
values.
2 #include <nlohmann/json.hpp>
12 std::cout <<
array[3] <<
'\n';
18 std::cout <<
array <<
'\n';
24 std::cout <<
array <<
'\n';
Output (play with this example online): 4
[1,2,3,4,6]
[1,2,3,4,6,null,null,null,null,null,11]
The example code above can be translated withg++ -std=c++11 -Isingle_include doc/examples/operatorarray__size_type.cpp -o operatorarray__size_type