| 407 | |
| 408 | |
| 409 | json parse_json_string(std::string j_dat) { |
| 410 | |
| 411 | json j_null; |
| 412 | try { |
| 413 | auto j = json::parse(j_dat); |
| 414 | return j; |
| 415 | } catch (nlohmann::detail::type_error & e) { |
| 416 | std::cout << json_type_error << " : " << e.what() << std::endl; |
| 417 | } catch (nlohmann::detail::parse_error const& e) { |
| 418 | std::cout << json_parse_error << " : " << e.what() << std::endl; |
| 419 | } catch (nlohmann::detail::invalid_iterator const& e) { |
| 420 | std::cout << json_invalid_iterator_error << " : " << e.what() << std::endl; |
| 421 | } catch (nlohmann::detail::out_of_range const& e) { |
| 422 | std::cout << json_out_of_range_error << " : " << e.what() << std::endl; |
| 423 | } catch (nlohmann::detail::other_error const& e) { |
| 424 | std::cout << json_other_error << " : " << e.what() << std::endl; |
| 425 | } catch (nlohmann::detail::exception const& e) { |
| 426 | std::cout << json_exception << " : " << e.what() << std::endl; |
| 427 | } |
| 428 | return j_null; |
| 429 | |
| 430 | } |
| 431 | |
| 432 | /////////////////////////////////////////////////////////////// |
| 433 | |