mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 08:46:19 +08:00
added first draft of docs
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# Error messages
|
||||
|
||||
reflect-cpp returns clear and comprehensive error messages:
|
||||
|
||||
```cpp
|
||||
const std::string faulty_json_string =
|
||||
R"({"firstName":"Homer","lastName":12345,"town":"Springfield","birthday":"04/19/1987","age":145,"email":"homer(at)simpson.com"})";
|
||||
const auto result = rfl::json::read<Person>(faulty_json_string);
|
||||
```
|
||||
|
||||
Yields the following error message:
|
||||
|
||||
```
|
||||
Found 5 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) Failed to parse field 'age': Value expected to be less than or equal to 130, but got 145.
|
||||
4) Failed to parse field 'email': String 'homer(at)simpson.com' did not match format 'Email': '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'.
|
||||
5) Field named 'children' not found.
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user