We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I tried to parse following invalid Json string
string bad_request_nothing = `{"content": "123"`;
my program has crashed with message
core.exception.RangeError at vibe.data.json(864): Range violation 0x00500CA0 in onRangeError ...
When I check out the string in data/json.d I recognized following line with issue
enforceJson(!range.empty && (range.front == ',' || range.front == '}'), "Expected '}' or ',' - got '"~range[0]~"'.");
It checks range on empty and throws error message with data from empty range simultaneously.
I can suggest the following solution:
enforceJson(!range.empty && (range.front == ',' || range.front == '}'), "Expected '}' or ',' - got "~(range.empty?"nothing.":"'"~range[0]~"'."));
and check it by following unittests
import vibe.vibe; import vibe.data.json : parseJsonString; unittest { string bad_request_nothing = `{"content": "123"`; try { Json request = parseJsonString(bad_request_nothing); } catch(JSONException e) { enforce(e.msg == "JSON format error at byte 17: Expected '}' or ',' - got nothing."); } } unittest { string bad_request_k = `{"content": "123"k`; try { Json request = parseJsonString(bad_request_k); } catch(JSONException e) { enforce(e.msg == "JSON format error at byte 17: Expected '}' or ',' - got 'k'."); } }
The text was updated successfully, but these errors were encountered:
04178e6
Fix range violation when building JSON parser error message. Fixes vi…
96a1278
…be-d#805.
No branches or pull requests
When I tried to parse following invalid Json string
my program has crashed with message
When I check out the string in data/json.d I recognized following line with issue
It checks range on empty and throws error message with data from empty range simultaneously.
I can suggest the following solution:
and check it by following unittests
The text was updated successfully, but these errors were encountered: