Skip to content

Commit

Permalink
Better JSON type mismatch errors (#1147)
Browse files Browse the repository at this point in the history
This changes the JSON parsing to use a std::variant so there just a
single OnValue handler vs OnString/OnNumber/OnBool/OnNull.

Previously a mismatched type would say

`JSON Error: Unknown value: name at line 3 index 19`

or it would say

`JSON Error: Unknown value: name`

if the name was known but the type of its value was wrong (example:
#1146).

Now it'll give a much better error message, showing first the full path
of the field being parsed, and then saying exactly how the types
mismatch:

`JSON Error: model:type - Expected a number but saw a string at line 3
index 19`
  • Loading branch information
RyanUnderhill authored Dec 18, 2024
1 parent d129274 commit c77e525
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 167 deletions.
Loading

0 comments on commit c77e525

Please sign in to comment.