MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / parse_with_comment

Function parse_with_comment

examples/src/json_parse_examples.cpp:10–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace jsoncons;
9
10void parse_with_comment()
11{
12 std::string s = R"(
13 {
14 // Single line comments
15 /*
16 Multi line comments
17 */
18 }
19 )";
20
21 // Default
22 {
23 auto j = json::parse(s);
24 std::cout << "(1) " << j << '\n';
25 }
26 // Strict
27 try
28 {
29 // until 0.170.0
30 auto j1 = json::parse(s, strict_json_parsing());
31
32 // since 0.171.0
33 auto options2 = json_options{}
34 .err_handler(strict_json_parsing());
35 auto j2 = json::parse(s, options2);
36
37 // since 1.3.0
38 auto options3 = json_options{}
39 .allow_comments(false);
40 auto j3 = json::parse(s, options3);
41 }
42 catch (const ser_error& e)
43 {
44 std::cout << "(2) " << e.what() << '\n';
45 }
46}
47
48void parse_with_trailing_commas()
49{

Callers 1

mainFunction · 0.85

Calls 4

parseFunction · 0.85
strict_json_parsingClass · 0.85
allow_commentsMethod · 0.80
whatMethod · 0.45

Tested by

no test coverage detected