This is a valid json
:
[{"id":1, "name":"foo"}, {"id":2, "name":"bar"}]
How do I create a TSuperObject
from this string
?
This is a valid json
:
[{"id":1, "name":"foo"}, {"id":2, "name":"bar"}]
How do I create a TSuperObject
from this string
?
If you open the readme.html
inside a browser you will see at the very first beginning of that document:
var
obj: ISuperObject;
begin
obj := SO('{"foo": true}');
obj := TSuperObject.ParseString('{"foo": true}');
obj := TSuperObject.ParseStream(stream);
obj := TSuperObject.ParseFile(FileName);
end;
There is a bug for Delphi 6.
When the SO()
function tries to convert the value of the string, it raises EIntOverflow
.
The bug is due to this function:
class function TSuperAvlEntry.Hash(const k: SOString): Cardinal;
This is the bug in the google's issue tracker
The workaround proposed by the bug's reporter is changing the function to this:
class function TSuperAvlEntry.Hash(const k: SOString): Cardinal;
var
h: cardinal;
i: Integer;
begin
h := 0;
{$Q-}
for i := 1 to Length(k) do
h := Cardinal( h*129 + ord(k[i]) + $9e370001);
Result := h;
end;
{$Q+}