1. 要得到的Json数据:[{"name":"张三","age": 17},{"name":"李四","age":20}]
function GetArrayJson: string; function GetPersonSO(const AName: string; AAge: Integer): ISuperObject;
begin
Result := SO;
Result.S['name'] := AName;
Result.I['age'] := AAge;
end; var
vJa: ISuperObject;
begin
vJa := SA([]);
vJa.AsArray.Add(GetPersonSO('张三', ));
vJa.AsArray.Add(GetPersonSO('李四', ));
Result := vJa.AsJson;17 end;
2. 要得到的Json数据:{“data”:[{"name":"张三","age": 17},{"name":"李四","age":20}]}
function GetDataJson: string; function GetPersonSO(const AName: string; AAge: Integer): ISuperObject;
begin
Result := SO;
Result.S['name'] := AName;
Result.S['age'] := AAge;
end; function GetArraySO: ISuperObject;
begin
Result := SA([]);
Result.AsArray.Add(GetPerson('张三', ));
Result.AsArray.Add(GetPerson('李四', ))
end; var
vJo: ISuperObject;
begin
vJo := SO;
vJo.O['data'] := GetArraySO;
Result := vJo.AsJson;
end;