Lines Matching full:json
2 // __| | __| | | | JSON for Modern C++ (supporting code)
4 // |_____|_____|_____|_|___| https://github.com/nlohmann/json
11 #include <nlohmann/json.hpp>
12 using nlohmann::json;
16 // create a JSON value with different types
17 const json json_types =
33 using test_type = json::object_t;
34 json value = {{"one", 1}, {"two", 2}};
46 CHECK_NOTHROW(value.get_ref<json::object_t&>());
47 CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
48 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
49 CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
50 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
51 CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
52 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
53 CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
54 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
55 CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
56 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
57 CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
58 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object", j…
63 using test_type = json::object_t;
64 const json value = {{"one", 1}, {"two", 2}};
77 using test_type = json::array_t;
78 json value = {1, 2, 3, 4};
90 CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
91 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
92 CHECK_NOTHROW(value.get_ref<json::array_t&>());
93 CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
94 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
95 CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
96 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
97 CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
98 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
99 CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
100 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
101 CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
102 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array", js…
107 using test_type = json::string_t;
108 json value = "hello";
120 CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
121 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
122 CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
123 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
124 CHECK_NOTHROW(value.get_ref<json::string_t&>());
125 CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
126 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
127 CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
128 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
129 CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
130 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
131 CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
132 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string", j…
137 using test_type = json::boolean_t;
138 json value = false;
150 CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
151 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
152 CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
153 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
154 CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
155 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
156 CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
157 CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
158 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
159 CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
160 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
161 CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
162 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean", …
167 using test_type = json::number_integer_t;
168 json value = -23;
180 CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
181 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
182 CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
183 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
184 CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
185 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
186 CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
187 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
188 CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
189 CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
190 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
191 CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
192 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
197 using test_type = json::number_unsigned_t;
198 json value = 23u;
210 CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
211 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
212 CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
213 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
214 CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
215 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
216 CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
217 …"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", j…
218 //CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
219 …// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is numb…
220 CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>());
221 …alue.get_ref<json::number_float_t&>(), "[json.exception.type_error.303] incompatible ReferenceType…
226 using test_type = json::number_float_t;
227 json value = 42.23;
239 …S(value.get_ref<json::object_t&>(), "[json.exception.type_error.303] incompatible ReferenceType fo…
240 …S(value.get_ref<json::array_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for…
241 …S(value.get_ref<json::string_t&>(), "[json.exception.type_error.303] incompatible ReferenceType fo…
242 …(value.get_ref<json::boolean_t&>(), "[json.exception.type_error.303] incompatible ReferenceType fo…
243 …lue.get_ref<json::number_integer_t&>(), "[json.exception.type_error.303] incompatible ReferenceTyp…
244 …ue.get_ref<json::number_unsigned_t&>(), "[json.exception.type_error.303] incompatible ReferenceTyp…
245 CHECK_NOTHROW(value.get_ref<json::number_float_t&>());