Closed skrzacikus closed 3 years ago
Confirmed, we have the same problem
I fixed like this, but must be another solution
Json2: string;
begin
Clear;
Json2 := StringReplace(Json, '\"\"', '\"', [rfReplaceAll]);
C := PChar(Json2);
+1
I ran into this issue today. If the Json string (a property value) contains title="" it is encoded as title=\"\" which the parser chokes on. If there is a space between the two \"\" there isn't a problem. I found this when my property value was a description containing an HTML link.
I confirm this. TryParse('["XS\"\"\"."]') fails, whereas this is valid JSON.
My quick fix was a dirty goto (the fastest to write):
if C^ = '"' then
begin
repeat
fix: Inc(C);
if C^ = '\' then
begin
Inc(C);
if C^ = '"' then
goto fix
else if C^ = 'u' then
The library should have more testing.
If you are interested, some benchmarks against other libraries at https://forum.lazarus.freepascal.org/index.php/topic,46533.msg413367.html#msg413367
jsontools in 51.41ms, 38.1 MB/s
fpjson in 79.36ms, 24.7 MB/s
SuperObject in 187.79ms, 10.4 MB/s
mORMot 2 TDocVariant in 118.81ms, 165 MB/s
mORMot 2 TOrmTableJson in 41.26ms, 475.1 MB/s
mORMot 2 DynArrayLoadJson in 62.02ms, 316 MB/s
Fixing in pending update. Thanks for reporting.
Your parser gives error when there is
\"\"
in JSON value. i.e.{"test": "one \"\"two\"\" three"}
I managed to avoid error replacing
\"\"
with\"
before parsing JSON. But it would be nice if your parser would deal with this.