| 8 | using namespace jsoncons; |
| 9 | |
| 10 | void 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 | |
| 48 | void parse_with_trailing_commas() |
| 49 | { |
no test coverage detected