mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
19902abaf8
* Guarding first/second access. * Correcting our own usage. * Adding more documentation.
28 lines
721 B
C++
28 lines
721 B
C++
|
|
#include <iostream>
|
|
#include "simdjson.h"
|
|
|
|
using namespace simdjson;
|
|
|
|
int main() {
|
|
auto json = "1"_padded;
|
|
ondemand::parser parser;
|
|
ondemand::document doc;
|
|
auto error = parser.iterate(json).get(doc);
|
|
if(error) { return EXIT_FAILURE; }
|
|
simdjson_result<ondemand::value> query = doc.at_pointer("/");
|
|
#if COMPILATION_TEST_USE_FAILING_CODE
|
|
if(query.second == simdjson::SUCCESS) {
|
|
std::cout << "success" << std::endl;
|
|
std::cout << query.first << std::endl;
|
|
}
|
|
#else
|
|
ondemand::value val;
|
|
error = query.get(val);
|
|
if(error == simdjson::SUCCESS) {
|
|
std::cout << "success" << std::endl;
|
|
std::cout << val << std::endl;
|
|
}
|
|
#endif
|
|
return EXIT_SUCCESS;
|
|
} |