File tree 1 file changed +27
-0
lines changed 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 5
5
* @mainpage
6
6
*
7
7
* Check the [README.md](https://github.com/lemire/simdjson/blob/master/README.md#simdjson--parsing-gigabytes-of-json-per-second).
8
+ *
9
+ * Sample code. See https://github.com/simdjson/simdjson/blob/master/doc/basics.md for more examples.
10
+
11
+ #include "simdjson.h"
12
+
13
+ int main(void) {
14
+ // load from `twitter.json` file:
15
+ simdjson::dom::parser parser;
16
+ simdjson::dom::element tweets = parser.load("twitter.json");
17
+ std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
18
+
19
+ // Parse and iterate through an array of objects
20
+ auto abstract_json = R"( [
21
+ { "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
22
+ { "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
23
+ ] )"_padded;
24
+
25
+ for (simdjson::dom::object obj : parser.parse(abstract_json)) {
26
+ for(const auto& key_value : obj) {
27
+ cout << "key: " << key_value.key << " : ";
28
+ simdjson::dom::object innerobj = key_value.value;
29
+ cout << "a: " << double(innerobj["a"]) << ", ";
30
+ cout << "b: " << double(innerobj["b"]) << ", ";
31
+ cout << "c: " << int64_t(innerobj["c"]) << endl;
32
+ }
33
+ }
34
+ }
8
35
*/
9
36
10
37
#include " simdjson/compiler_check.h"
You can’t perform that action at this time.
0 commit comments