Before Rio, I colud do something like this:
Procedure AddValue(pObj: TJSONObject; pName: String; pJSONValue: TJSONValue);
var vJsonPair: TJsonPair;
begin
vJsonPair:= pObj.Get(pName);
if Assigned(vJsonPair) then
begin
//preserving the place
vJsonPair.JsonValue.free;
vJsonPair.JsonValue:= pJSONValue;
end
else
pObj.AddPair(pName, pJSONValue);
end;
But, with Rio+, I must to do this:
Procedure AddValue(pObj: TJSONObject; pName: String; pJSONValue: TJSONValue);
var vJsonPair: TJsonPair;
begin
vJsonPair:= pObj.Get(pName);
if Assigned(vJsonPair) then
begin
//putting the pair at the end of the object
pObj.RemovePair(pName);
pObj.AddPair(pName, pJSONValue);
end
else
pObj.AddPair(pName, pJSONValue);
end;
So, with Delphi System.JSON, you have to check if the pair exists to replace it. And from Rio, you have to delete and create the pair again