#include "simdjson.h" #include #include #include #include #include #include "NullBuffer.h" // example from doc/basics.md#tree-walking-and-json-element-types static void print_json(std::ostream& os, simdjson::dom::element element) { const char endl='\n'; switch (element.type()) { case simdjson::dom::element_type::ARRAY: os << "["; for (simdjson::dom::element child : element.get().first) { print_json(os, child); os << ","; } os << "]"; break; case simdjson::dom::element_type::OBJECT: os << "{"; for (simdjson::dom::key_value_pair field : element.get().first) { os << "\"" << field.key << "\": "; print_json(os, field.value); } os << "}"; break; case simdjson::dom::element_type::INT64: os << element.get().first << endl; break; case simdjson::dom::element_type::UINT64: os << element.get().first << endl; break; case simdjson::dom::element_type::DOUBLE: os << element.get().first << endl; break; case simdjson::dom::element_type::STRING: os << element.get().first << endl; break; case simdjson::dom::element_type::BOOL: os << element.get().first << endl; break; case simdjson::dom::element_type::NULL_VALUE: os << "null" << endl; break; } } extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { simdjson::dom::parser parser; simdjson::error_code error; simdjson::dom::element elem; parser.parse(Data, Size).tie(elem, error); if (error) { return 1; } NulOStream os; //std::ostream& os(std::cout); print_json(os,elem); return 0; }