ahausladen / JsonDataObjects

JSON parser for Delphi 2009 and newer
MIT License
413 stars 160 forks source link

Can't parse mixed types in an array #39

Closed khongten001 closed 6 years ago

khongten001 commented 6 years ago

Hi, The JsonDataObjects can't parse this json string:

[1,2,3,\"This is a test\",{\"a\":\"a\"}]

You can get that json string by executing this code in Firefox or Chrome:

JSON.stringify([1, 2, 3, "This is a test", {"a": "a"}]);
ahausladen commented 6 years ago

That's no valid JSON. That's how a C based programming language needs the string in the code editor. The string that is returned by JSON.stringify() doesn't contain the escape characters. If you use console.log() to output the string to the console you see that there are no escape characters. Furthermore the length of the returned string is 34 and not 40.

console.log(JSON.stringify([1, 2, 3, "This is a test", {"a": "a"}]));
console.log(JSON.stringify([1, 2, 3, "This is a test", {"a": "a"}]).length);

outputs:

[1,2,3,"This is a test",{"a":"a"}]
34