You are not logged in.
Pages: 1
In TJSONCustomParserRTTI.ReadOneLevel():
(Using the nightly build dated 2016-01-16)
ptCustom:
P := TJSONCustomParserCustom(Prop).CustomReader(P,Data^,EndOfObject);
Needs to be:
ptCustom: begin
P := TJSONCustomParserCustom(Prop).CustomReader(P,Data^,EndOfObject);
if P=nil then
exit;
end;
Otherwise the parsing continues and data corruption can occur.
I'm using this with RecordLoadJSON() and the problem happened in a nested record, when an integer was expected, but a string value was specified.
Currently, RecordLoadJSON() returns nil if the JSON was not valid, but it would be incredibly helpful if there was a way to validate the JSON against the record/object it's being de-serialzed to, so that I can see exactly where the parsing failed, instead of having to hunt through some large JSON strings (especially with nested objects and arrays) to find the offending syntax or type mismatch. It's like hunting for a needle in a haystack.
Even having a separate function to perform this kind of validation would be extremely useful!
Last edited by avista (2016-01-19 20:29:51)
Offline
Should be fixed by http://synopse.info/fossil/info/bab3b6f191
I've also ensured TJSONCustomParserRTTI.ReadOneLevel would let P point on the faulty text on parse error. This should be the first step to ease JSON validation.
Offline
Pages: 1