首先下载SuperObject 代码包
官网 http://www./?page_id=6
下载地址 http://code.google.com/p/superobject/downloads/list
官方论坛 http://www./forums/viewforum.php?f=5
好,开始例子
var
obj: ISuperObject;
begin
obj := SO('{"foo": true}'); //创建对象
memo1.lines.add(obj.asobject.s['foo']); //读取为字符
end;
提示 Integer overflow
修改superobject.pas源文件中的
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 := h*129 + ord(k[i]) + $9e370001;
{$Q+}
Result := h;
end;
修改为如下代码:
{$UNDEF SaveQ} {$IFOPT Q+} {$Q-} {$DEFINE SaveQ} {$ENDIF}
class function TSuperAvlEntry.Hash(const k: SOString): Cardinal;
var
h: cardinal;
i: Integer;
begin
h := 0;
for i := 1 to Length(k) do
h := h*129 + ord(k[i]) + $9e370001;
Result := h;
end;
{$IFDEF SaveQ} {$Q+} {$UNDEF SaveQ} {$ENDIF}
然后重新编译执行,成功!