| 25 | //---------------------------------------------------------- |
| 26 | |
| 27 | static void set1() { |
| 28 | |
| 29 | //---------------------------------------------------------- |
| 30 | { |
| 31 | // tag::doc_parsing_1[] |
| 32 | value jv = parse( "[1,2,3,4,5]" ); |
| 33 | // end::doc_parsing_1[] |
| 34 | } |
| 35 | //---------------------------------------------------------- |
| 36 | { |
| 37 | // tag::doc_parsing_2[] |
| 38 | boost::system::error_code ec; |
| 39 | value jv = parse( "[1,2,3,4,5]", ec ); |
| 40 | if( ec ) |
| 41 | std::cout << "Parsing failed: " << ec.message() << "\n"; |
| 42 | // end::doc_parsing_2[] |
| 43 | } |
| 44 | //---------------------------------------------------------- |
| 45 | { |
| 46 | // tag::doc_parsing_3[] |
| 47 | try |
| 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 | } |
| 54 | catch( 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[] |
| 70 | parse_options opt; // all extensions default to off |
| 71 | opt.allow_comments = true; // permit C and C++ style comments |
| 72 | // to appear in whitespace |
| 73 | opt.allow_trailing_commas = true; // allow an additional trailing comma in |
| 74 | // object and array element lists |
| 75 | opt.allow_invalid_utf8 = true; // skip utf-8 validation of keys and strings |
| 76 | opt.allow_invalid_utf16 = true; // replace invalid surrogate pair UTF-16 code point(s) |
| 77 | // with the Unicode replacement character |
| 78 | |
| 79 | value jv = parse( "[1,2,3,] // comment ", storage_ptr(), opt ); |
| 80 | // end::doc_parsing_5[] |
| 81 | } |
| 82 | //---------------------------------------------------------- |
| 83 | { |
| 84 | #if __cpp_designated_initializers >= 201707L |
nothing calls this directly
no test coverage detected