]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/operatorarray__size_type.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / examples / operatorarray__size_type.cpp
CommitLineData
1e59de90
TL
1#include <iostream>
2#include <nlohmann/json.hpp>
3
4using json = nlohmann::json;
5
6int main()
7{
8 // create a JSON array
9 json array = {1, 2, 3, 4, 5};
10
11 // output element at index 3 (fourth element)
12 std::cout << array[3] << '\n';
13
14 // change last element to 6
15 array[array.size() - 1] = 6;
16
17 // output changed array
18 std::cout << array << '\n';
19
20 // write beyond array limit
21 array[10] = 11;
22
23 // output changed array
24 std::cout << array << '\n';
25}