.AsString returning weird string when converted from integer.
Hi, The "steamid" field used to be a type of string but they changed it and now it's returned as a integer. When using .AsString to get the value it gives the following: "7,65611981130345E16" instead of "76561198113034550"
Json Data:
[
{
"steamid": 76561198113034550,
"group": "Banned",
"username": "Quantum",
"notes": "Test Ban",
"expiry": 1603633669
}
]
This is because it is too big to be stored as an integer (max int value: 2 147 483 647), so it gets stored as a Float, which can easily hold numbers up to 1E308 (losing precision in the process). The default conversion from float to string is "use the least amount of space" which, in your case gives you scientific notation.
To fix the bug, TdJSON would need a function, where it parses and thereby stores all data (Integer/Numbers at least) as string. Now, this is possible (in fact it was until Merge #23) but brings some other problems (besides, storing integers as integers instead of strings sounds more logical :P). To implement this is no big deal, but @thomaserlang has to decide.
I actually forgot about this. I ended up moving over the built in json parser that delphi provides.
actually, if all numbers you get are around 16 digits, they fit into a int64. I found our that whoever did the Integer read implementation never thought about separating Int, Int64 and Float (Double). Spoiler: It was me. I fixed it in my local unit, it now distinguishes between Integer, Int64 and Double. Whether i can do a merge request is still open because i also changed some other stuff which prevents auto-merging.