Files
simdjson-simdjson/examples/quickstart/quickstart_ondemand_noexceptions.cpp
T
John Keiser 17f4f82827 Ondemand usage docs (and associated tests)
Also disallowed parsing a temporary padded_string, since the JSON *must*
live through the whole parse.
2021-01-01 19:17:58 -08:00

22 lines
675 B
C++

#include "simdjson.h"
using namespace simdjson;
using namespace simdjson::builtin;
int main(void) {
padded_string json;
auto error = padded_string::load("twitter.json").get(json);
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
ondemand::parser parser;
ondemand::document tweets;
error = parser.iterate(json).get(tweets);
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
uint64_t count;
error = tweets["search_metadata"]["count"].get(count);
if (error) { std::cerr << error << std::endl; return EXIT_FAILURE; }
std::cout << count << " results." << std::endl;
return EXIT_SUCCESS;
}