我正在将一些项目从Delphi 10.4迁移到Delphi 11.3. 我在JSON库方面遇到了一些问题:
请参阅以下代码:
第一个 case :
function TestCreate;
var
LValue: Variant;
LJSON: TJSONNumber;
begin
LValue := 100;
LJSON := TJSONNumber.Create(LValue);
end;
汇编这篇文章后,结果是:
[dcc64 Error] _Unit.pas(74): E2251 Ambiguous overloaded call to 'Create'
System.JSON.pas(435): Related method: constructor TJSONNumber.Create(const string);
System.JSON.pas(439): Related method: constructor TJSONNumber.Create(const Double);
第二个 case :
function TestAddPair;
var
LValue: Variant;
LJSON: TJSONObject;
begin
LValue := 100;
LJSON := TJSONObject.Create();
LJSON.AddPair('Test', LValue);
end;
汇编这篇文章后,结果是:
[dcc64 Error] _Unit.pas(77): E2251 Ambiguous overloaded call to 'AddPair'
System.JSON.pas(661): Related method: function TJSONObject.AddPair(const string; const Boolean): TJSONObject;
System.JSON.pas(651): Related method: function TJSONObject.AddPair(const string; const Double): TJSONObject;
System.JSON.pas(636): Related method: function TJSONObject.AddPair(const string; const string): TJSONObject;
这两种方法在Delphi 10.4上都可以正常运行,但在Delphi 11.3上无法编译. 有没有办法让它们编译?我不希望修改每个使用变体来创建/添加JSON的命令.