@@ -124,6 +124,27 @@ for (dom::object car : parser.parse(cars_json)) {
124124}
125125```
126126
127+ Here is a different example illustrating the same ideas:
128+
129+ ``` C++
130+ auto abstract_json = R"( [
131+ { "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
132+ { "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
133+ ] )" _padded;
134+ dom::parser parser;
135+
136+ // Parse and iterate through an array of objects
137+ for (dom::object obj : parser.parse(abstract_json)) {
138+ for(const auto& key_value : obj) {
139+ cout << "key: " << key_value.key << " : ";
140+ dom::object innerobj = key_value.value;
141+ cout << "a: " << double(innerobj["a"]) << ", ";
142+ cout << "b: " << double(innerobj["b"]) << ", ";
143+ cout << "c: " << int64_t(innerobj["c"]) << endl;
144+ }
145+ }
146+ ```
147+
127148C++17 Support
128149-------------
129150
@@ -277,6 +298,49 @@ for (auto field : car) {
277298}
278299```
279300
301+ Here is another example:
302+
303+ ``` C++
304+ auto abstract_json = R"( [
305+ { "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
306+ { "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
307+ ] )" _padded;
308+ dom::parser parser;
309+ dom::array rootarray;
310+ simdjson::error_code error;
311+ parser.parse(abstract_json).get<dom::array>().tie(rootarray, error);
312+ if (error) { cerr << error << endl; exit(1); }
313+ // Iterate through an array of objects
314+ for (dom::element elem : rootarray) {
315+ dom::object obj;
316+ elem.get< dom::object > ().tie(obj, error);
317+ if (error) { cerr << error << endl; exit(1); }
318+ for(auto & key_value : obj) {
319+ cout << "key: " << key_value.key << " : ";
320+ dom::object innerobj;
321+ key_value.value.get< dom::object > ().tie(innerobj, error);
322+ if (error) { cerr << error << endl; exit(1); }
323+
324+ double va;
325+ innerobj["a"].get<double>().tie(va, error);
326+ if (error) { cerr << error << endl; exit(1); }
327+ cout << "a: " << va << ", ";
328+
329+ double vb;
330+ innerobj["b"].get<double>().tie(vb, error);
331+ if (error) { cerr << error << endl; exit(1); }
332+ cout << "b: " << vb << ", ";
333+
334+ int64_t vc;
335+ innerobj["c"].get<int64_t>().tie(vc, error);
336+ if (error) { cerr << error << endl; exit(1); }
337+ cout << "c: " << vc << endl;
338+
339+ }
340+ }
341+
342+ ```
343+
280344### Exceptions
281345
282346Users more comfortable with an exception flow may choose to directly cast the ` simdjson_result<T> ` to the desired type:
0 commit comments