1 | #ifndef SIMDJSON_H |
2 | #define SIMDJSON_H |
3 | |
4 | /** |
5 | * @mainpage |
6 | * |
7 | * Check the [README.md](https://github.com/simdjson/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 | } |
35 | */ |
36 | |
37 | #include "simdjson/simdjson_version.h" |
38 | #include "simdjson/dom.h" |
39 | #include "simdjson/builtin.h" |
40 | |
41 | #endif // SIMDJSON_H |
42 | |