mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 10:46:18 +08:00
Documented good error messages
This commit is contained in:
@@ -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<Person>(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
|
||||
|
||||
Reference in New Issue
Block a user