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

Function parse_json

example/check_error_offset.cpp:6–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "sonic/sonic.h"
5
6void parse_json(const std::string& data) {
7 sonic_json::Document doc;
8 doc.Parse(data);
9 if (doc.HasParseError()) {
10 std::cout << sonic_json::ErrorMsg(doc.GetParseError()) << std::endl
11 << "Json: \n"
12 << data << std::endl
13 << "Error offset is: " << doc.GetErrorOffset() << std::endl;
14 } else {
15 std::cout << "Parse json:\n" << data << "\n successfully";
16 }
17}
18
19int main() {
20 parse_json(R"({"a":"b",)");

Callers 1

mainFunction · 0.70

Calls 5

ErrorMsgFunction · 0.85
ParseMethod · 0.80
HasParseErrorMethod · 0.80
GetParseErrorMethod · 0.80
GetErrorOffsetMethod · 0.80

Tested by

no test coverage detected