MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / object_range_based_for_loop

Function object_range_based_for_loop

examples/src/examples.cpp:187–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void object_range_based_for_loop()
188{
189 json j = json::parse(R"(
190{
191 "category" : "Fiction",
192 "title" : "Pulp",
193 "author" : "Charles Bukowski",
194 "date" : "2004-07-08",
195 "price" : 22.48,
196 "isbn" : "1852272007"
197}
198)");
199
200 for (const auto& member : j.object_range())
201 {
202 std::cout << member.key() << " => " << member.value().as<std::string>() << '\n';
203 }
204
205#if defined(JSONCONS_HAS_2017)
206 // or, since 0.176.0, using C++ 17 structured binding
207 for (const auto& [key, value] : j.object_range())
208 {
209 std::cout << key << " => " << value << '\n';
210 }
211#endif
212}
213
214void validation_example()
215{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected