ahausladen / JsonDataObjects

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

UTF8 Error #33

Closed lynch9983 closed 7 years ago

lynch9983 commented 7 years ago

When I use JsonDataObjects,pas (in Delphi XE) like this:

procedure doParseUTF8(); var aJson: TJsonObject; aJsonStr: string; aUTF8Str: UTF8String; begin aJsonStr := '{"123":{"abc":{"efg":"hij"}}}'; aUTF8Str := UTF8Encode(aJsonStr);

aJson := TJsonObject.Create; try aJson.FromUtf8JSON(aUTF8Str); ShowMessage(aJson.ToJSON); finally aJson.Free; end; end;

I get message '{"12":{"ab":{"ef":"hi"}}}'. The Key and The Value all have been cut.

this Error also in parse from UTF8 file.

ahausladen commented 7 years ago

I can't reproduce this behavior if I run your code (neither in XE nor in 10.1). Did you use the newest source code?

lynch9983 commented 7 years ago

JsonUTF8.zip This is all my test codes ( in XE ).

And, if I edit the procedure

" TUtf8JsonReader.LexString"

line 5759: SetStringUtf8(FLook.S, P, EndP - P) // before edit

to

line 5759: SetStringUtf8(FLook.S, P, EndP - P + 1) //after edit

after edit, my test run ok.

ahausladen commented 7 years ago

Do you have XE Update 1 installed? I have and I don't see that bug with your test application. The only thing that could be different is Utf8ToUnicode.

lynch9983 commented 7 years ago

I run it in XE( with Update 1 ), the demo run OK. I'm sorry to bother you.