You are not logged in.
I use a rawjson as interface base service input param, a illegal json will crash the program.
test code:
const
vJson = '{"id": 1, "name": ''Tom''}'; //<- illegal json
var
v: TDocVariantData;
begin
writeln(vJson,' is good json:',IsValidJson(vJson));
if v.InitJSON(vJson, JSON_OPTIONS_FAST) then //<- cause av
writeln(v.I['id'], ' ', v.U['name'])
else
writeln('bad json');
end.
{"id": 1, "name": 'Tom'} is good json:TRUE
An unhandled exception occurred at $000000010004AC53:
EAccessViolation: Access violation
$000000010004AC53 InitJsonInPlace, line 5357 of ../../src/core/mormot.core.variants.pas
$000000010004AD69 InitJson, line 5381 of ../../src/core/mormot.core.variants.pas
$0000000100001B75 main, line 27 of project1.lpr
Offline
You are right.
Error should be fixed by https://github.com/synopse/mORMot2/commit/9d929d33
Note that IsValidJson() is with strict=false by default, meaning a single quote is allowed for values.
IsValidJson(vJson, true) returns false as expected.
I have added extended/non-standard 'text' single quoted content as (extended) JSON value input, so that IsValidJson() is coherent with our value.
Now your input would be allowed, and allow 'Tom' as value - since we support JSON with some extension.
See https://github.com/synopse/mORMot2/commit/28f4baa9
Offline
Great, more and more stable. Thank you.
Offline