From d2d918c5955c15b8110044ce5223c562e00d30be Mon Sep 17 00:00:00 2001 From: liuzicheng1987 Date: Sat, 21 Oct 2023 14:24:16 +0200 Subject: [PATCH] Documented good error messages --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 59fb3049..146d2aec 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,23 @@ std::cout << "Hello, my name is " << homer2.first_name() << " " << homer2.last_name() << "." << std::endl; ``` +reflect-cpp returns clear and comprehensive error messages: + +```cpp +const std::string faulty_json_string = + R"({"firstName":"Homer","lastName":12345,"birthday":"04/19/1987"})"; +const auto result = rfl::json::read(faulty_json_string); +``` + +Yields the following error message: + +``` +Found 3 errors: +1) Failed to parse field 'lastName': Could not cast to string. +2) Failed to parse field 'birthday': String '04/19/1987' did not match format '%Y-%m-%d'. +3) Field named 'children' not found. +``` + ## Support for containers ### C++ standard library