Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToJson has some bug! #71

Open
iamnewaplayer opened this issue Aug 18, 2022 · 8 comments
Open

ToJson has some bug! #71

iamnewaplayer opened this issue Aug 18, 2022 · 8 comments

Comments

@iamnewaplayer
Copy link

src "_GCV_0_A": "24",
dst "_GCV_0d\u0000": "24",

I don't know what happened!
i used JsonDataObjects.ToJson() to save to Mongo
Sometimes this kind of error occurs
some string end error whit key or value

@PatrickvL
Copy link

PatrickvL commented Aug 18, 2022

If you're taking the trouble to report an issue, at least supply all relevant details. (And a small fully contained reproduction scenario)

@ahausladen
Copy link
Owner

I can't reproduce this with the following code:

procedure TestTJsonObject.TestIssue71;
var
  Json: TJsonObject;
  S: string;
begin
  Json := TJsonObject.Parse('{ "_GCV_0_A": "24" }') as TJsonObject;
  try
    CheckEquals(
      '{' + JsonSerializationConfig.LineBreak +
      JsonSerializationConfig.IndentChar + '"_GCV_0_A": "24"' + JsonSerializationConfig.LineBreak +
      '}' + JsonSerializationConfig.LineBreak, Json.ToJSON(False));
  finally
    Json.Free;
  end;
end;

You could try to disable one or both of the following defines:

  • USE_LAST_NAME_STRING_LITERAL_CACHE
  • USE_FAST_STRASG_FOR_INTERNAL_STRINGS

Maybe something is fishy with those optimizations, as the string seems to be modified. Or there is something else overwriting the memory outside of JsonDataObjects, that possibility always exists.

@iamnewaplayer
Copy link
Author

i try it,but do not work;
i have only one line use this

UserItem.Custom['GCV'+nAbilSite.ToString+'_A']:=nValue.ToString;

property Custom[const v: string]: String read GetStringValue write SetStringValue;
procedure TUserItem.SetStringValue(const v: string; Value: string);
begin
if v.Length>0 then
Values.O['Custom'].S[v] := Value;
end;

some time
UserItem.values.tojson has this error;
maybe key empty
maybe like _GCV_0d\u0000

i assign this Custom Value only this one line.

@iamnewaplayer
Copy link
Author

some places
i used
useritem.values = useritem.values.clone

@iamnewaplayer
Copy link
Author

like this

HumData.O['BagItems'].O[i.ToString] :=
pTUserItem(m_ItemList.Items[i]).Values.Clone;

@iamnewaplayer
Copy link
Author

i used delphi 11.0

@fastbike
Copy link

How about providing a project that reproduces the bug, so some others can test it for you. Leaving shouty comments on the ticket is of no use. Thanks.

@iamnewaplayer
Copy link
Author

can't reproduces the bug by myself..
it is occur in production environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants