MCPcopy Create free account
hub / github.com/boostorg/json / set1

Function set1

test/doc_parsing.cpp:27–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25//----------------------------------------------------------
26
27static void set1() {
28
29//----------------------------------------------------------
30{
31// tag::doc_parsing_1[]
32value jv = parse( "[1,2,3,4,5]" );
33// end::doc_parsing_1[]
34}
35//----------------------------------------------------------
36{
37// tag::doc_parsing_2[]
38boost::system::error_code ec;
39value jv = parse( "[1,2,3,4,5]", ec );
40if( ec )
41 std::cout << "Parsing failed: " << ec.message() << "\n";
42// end::doc_parsing_2[]
43}
44//----------------------------------------------------------
45{
46// tag::doc_parsing_3[]
47try
48{
49 boost::system::error_code ec;
50 value jv = parse( "[1,2,3,4,5]", ec );
51 if( ec )
52 std::cout << "Parsing failed: " << ec.message() << "\n";
53}
54catch( std::bad_alloc const& e)
55{
56 std::cout << "Parsing failed: " << e.what() << "\n";
57}
58// end::doc_parsing_3[]
59}
60//----------------------------------------------------------
61{
62// tag::doc_parsing_4[]
63 monotonic_resource mr;
64 value const jv = parse( "[1,2,3,4,5]", &mr );
65// end::doc_parsing_4[]
66}
67//----------------------------------------------------------
68{
69// tag::doc_parsing_5[]
70parse_options opt; // all extensions default to off
71opt.allow_comments = true; // permit C and C++ style comments
72 // to appear in whitespace
73opt.allow_trailing_commas = true; // allow an additional trailing comma in
74 // object and array element lists
75opt.allow_invalid_utf8 = true; // skip utf-8 validation of keys and strings
76opt.allow_invalid_utf16 = true; // replace invalid surrogate pair UTF-16 code point(s)
77 // with the Unicode replacement character
78
79value jv = parse( "[1,2,3,] // comment ", storage_ptr(), opt );
80// end::doc_parsing_5[]
81}
82//----------------------------------------------------------
83{
84#if __cpp_designated_initializers >= 201707L

Callers

nothing calls this directly

Calls 2

storage_ptrClass · 0.50
whatMethod · 0.45

Tested by

no test coverage detected