41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#ifndef SIMDJSON_H
|
|
#define SIMDJSON_H
|
|
|
|
/**
|
|
* @mainpage
|
|
*
|
|
* Check the [README.md](https://github.com/simdjson/simdjson/blob/master/README.md#simdjson--parsing-gigabytes-of-json-per-second).
|
|
*
|
|
* Sample code. See https://github.com/simdjson/simdjson/blob/master/doc/basics.md for more examples.
|
|
|
|
#include "simdjson.h"
|
|
|
|
int main(void) {
|
|
// load from `twitter.json` file:
|
|
simdjson::dom::parser parser;
|
|
simdjson::dom::element tweets = parser.load("twitter.json");
|
|
std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
|
|
|
|
// Parse and iterate through an array of objects
|
|
auto abstract_json = R"( [
|
|
{ "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
|
|
{ "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
|
|
] )"_padded;
|
|
|
|
for (simdjson::dom::object obj : parser.parse(abstract_json)) {
|
|
for(const auto key_value : obj) {
|
|
cout << "key: " << key_value.key << " : ";
|
|
simdjson::dom::object innerobj = key_value.value;
|
|
cout << "a: " << double(innerobj["a"]) << ", ";
|
|
cout << "b: " << double(innerobj["b"]) << ", ";
|
|
cout << "c: " << int64_t(innerobj["c"]) << endl;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
#include "simdjson/dom.h"
|
|
#include "simdjson/builtin.h"
|
|
|
|
#endif // SIMDJSON_H
|