ahausladen / JsonDataObjects

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

String parse error #46

Closed aschegolskiy closed 5 years ago

aschegolskiy commented 5 years ago

Following code rises Exception:

procedure TForm1.Button1Click(Sender: TObject); var jso: TJsonObject; begin jso := TJsonObject.Parse('{"ml_model": "J250'#$A'IMEI"}') as TJsonObject; jso.Free; end;

Project Project1.exe raised exception class EJsonParserException with message 'Invalid character in string (1, 19)'.

I checked that string complies with the JSON string specification.

ahausladen commented 5 years ago

$A is a control character and according to http://json.org those are not allowed in strings and must be escaped (in this case with "\n")

JSON string definition

aschegolskiy commented 5 years ago

Yes, #$A converted to newline for strings by the delphi compiler. But inside json string '#$A' is just unicode character sequence. I think that in diagram the control characters are: \n, \t \" etc. Are you agree with that?

aschegolskiy commented 5 years ago

You are right, in my example it is control character.