#include #include "simdjson.h" using namespace std; using namespace simdjson; void document_parse_error_code() { cout << __func__ << endl; auto [doc, error] = document::parse("[ 1, 2, 3 ]"_padded); if (error) { cerr << "Error: " << error << endl; exit(1); } cout << doc << endl; } void parser_parse_error_code() { cout << __func__ << endl; // Allocate a parser big enough for all files document::parser parser; // Read files with the parser, one by one for (padded_string json : { string("[1, 2, 3]"), string("true"), string("[ true, false ]") }) { cout << "Parsing " << json.data() << " ..." << endl; auto [doc, error] = parser.parse(json); if (error) { cerr << "Error: " << error << endl; exit(1); } cout << doc << endl; } } void parser_parse_many_error_code() { cout << __func__ << endl; // Read files with the parser auto json = "[1, 2, 3] true [ true, false ]"_padded; cout << "Parsing " << json.data() << " ..." << endl; document::parser parser; for (auto [doc, error] : parser.parse_many(json)) { if (error) { cerr << "Error: " << error << endl; exit(1); } cout << doc << endl; } } void parser_parse_max_capacity() { cout << __func__ << endl; int argc = 2; padded_string argv[] { string("[1,2,3]"), string("true") }; document::parser parser(1024*1024); // Set max capacity to 1MB for (int i=0;i