#include "jsonparser/jsonparser.h" // allocate a ParsedJson structure that can support document // up to len bytes. // returns NULL if memory cannot be allocated // This structure is meant to be reused from document to document, as needed. // you can use deallocate_ParsedJson to deallocate the memory. ParsedJson *allocate_ParsedJson(size_t len) { if (len > MAX_JSON_BYTES) { std::cerr << "Currently only support JSON files having up to "<structural_indexes; free(pj_ptr->structurals); delete pj_ptr; } // parse a document found in buf, need to preallocate ParsedJson. bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) { if (pj.bytecapacity < len) { std::cerr << "Your ParsedJson cannot support documents that big: " << len << std::endl; return false; } bool isok = find_structural_bits(buf, len, pj); if (isok) { isok = flatten_indexes(len, pj); } if (isok) { isok = ape_machine(buf, len, pj); } if (isok) { isok = shovel_machine(buf, len, pj); } return isok; }