MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / main

Function main

example/parse_schema.cpp:7–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "sonic/sonic.h"
6
7int main() {
8 std::string json_schema = R"(
9 {"obj":1}
10 )";
11
12 std::string json = R"(
13{"it":1, "obj":{"a":{"b":1}, "b":[1]}}
14 )";
15
16 sonic_json::Document doc;
17 doc.Parse(json_schema);
18 if (doc.HasParseError()) std::cout << "error\n";
19 // doc.Parse(json_schema);
20
21 doc.ParseSchema(json);
22 if (doc.HasParseError()) {
23 std::cout << "json: " << json.substr(doc.GetErrorOffset()) << std::endl;
24 }
25 std::cout << "schema : " << doc.Dump() << std::endl;
26}
27// g++ -I../include/ -march=haswell --std=c++11 parse_schema.cpp -o
28// parse_schema

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.80
HasParseErrorMethod · 0.80
GetErrorOffsetMethod · 0.80
DumpMethod · 0.80

Tested by

no test coverage detected