vibe.d
vibe.d copied to clipboard
Json error messages can be improved
When you're deserializing json and if you have a misspelling for one of your entries.
Ex. if you have this class:
class Foo { int bar; string test; }
But your json looks like this:
{
"baz": 0,
"test": "..."
}
Then you'll get following error message:
std.json.JSONException@.......\vibe-d\data\vibe\data\json.d(1858): Expecting ',' or '}
', not '0'.
But obviously it's not because your json syntax is invalid, but it's because the json entry doesn't match the member of the class you're deserializing to.
That may not be an obvious error if you have large json data.
It's triggered here: https://github.com/vibe-d/vibe.d/blob/2692810e73ac2eb82ebf41af469b9ef7af1847de/data/vibe/data/json.d#L1858
This isn't even just a bad error message since something like {"baz": 0, "bar": 0, "test": "..."}
would fail as well, while it should actually pass. What's missing is a skipValue()
that is called when the field name is unknown.
This may be related to #1647
Note: There was a PR for it too: https://github.com/vibe-d/vibe.d/pull/1622