27 using key_type = json::key_type;
28 using mapped_type = json;
29 using value_type = std::pair<const key_type, mapped_type>;
30 using size_type = size_t;
31 using iterator = json::object_iterator;
32 using const_iterator = json::const_object_iterator;
34 object_type() =
default;
35 object_type(
const object_type& o) : json_(o) {}
36 explicit object_type(
const json& j) : json_(j) {}
37 explicit object_type(object_type&& o) noexcept : json_(std::move(o)) {}
38 ~object_type() =
default;
40 object_type& operator=(
const object_type& o) {
45 object_type& operator=(object_type&& o)
noexcept {
46 json_ = std::move(o.json_);
51 mapped_type& operator[](
const key_type& key) {
return json_[key]; }
54 const mapped_type& at(
const key_type& key)
const {
return json_.at(key); }
57 size_type count(
const key_type& key)
const {
return json_.count(key); }
59 iterator begin() {
return json_.object_range().begin(); }
60 iterator end() {
return json_.object_range().end(); }
61 const_iterator begin()
const {
return json_.object_range().cbegin(); }
62 const_iterator end()
const {
return json_.object_range().cend(); }
63 const_iterator cbegin()
const {
return json_.object_range().cbegin(); }
64 const_iterator cend()
const {
return json_.object_range().cend(); }
71 using value_type = json;
72 using size_type = size_t;
73 using iterator = json::array_iterator;
74 using const_iterator = json::const_array_iterator;
76 array_type() =
default;
77 array_type(
const array_type& a) : json_(a) {}
78 explicit array_type(
const json& j) : json_(j) {}
79 explicit array_type(array_type&& a) noexcept : json_(std::move(a)) {}
80 array_type(std::initializer_list<value_type> init) : json_(json::array()) {
81 for (
auto const& v : init) {
85 template<
typename Iterator>
86 array_type(Iterator first, Iterator last) : json_(json::array()) {
87 for (
auto it = first; it != last; ++it) {
91 ~array_type() =
default;
93 array_type& operator=(
const array_type& o) {
98 array_type& operator=(array_type&& o)
noexcept {
99 json_ = std::move(o.json_);
103 value_type& operator[](size_type index) {
return json_[index]; }
105 const value_type& at(size_type index)
const {
return json_.at(index); }
107 value_type
const& front()
const {
return json_.at(0); }
109 size_type size()
const {
return json_.size(); }
111 bool empty()
const {
return json_.empty(); }
113 void push_back(
const value_type& val) { json_.push_back(val); }
115 iterator begin() {
return json_.array_range().begin(); }
116 iterator end() {
return json_.array_range().end(); }
117 const_iterator begin()
const {
return json_.array_range().cbegin(); }
118 const_iterator end()
const {
return json_.array_range().cend(); }
119 const_iterator cbegin()
const {
return json_.array_range().cbegin(); }
120 const_iterator cend()
const {
return json_.array_range().cend(); }