I'm trying to copy from one JSON to second object type array (named 'items'). However, when copying, the second JSON always creates only an empty 'items' field with no items (lenght 0) . Please advise
FSobj := TSuperObject.ParseFile( wBaseJSON, True);
if Assigned(FSobj) then
begin
...
wObjItems := FSobj.o[ID].o['items'];
if not(Assigned(wObjItems)) then
begin
wSobjDet := TSuperObject.ParseFile( wJsonsDetFolder + ID + '.json', True);
if Assigned(wSobjDet) then
begin
if Assigned(wSobjDet.A['items']) then
begin
FSobj.o[ID].o['items'] := SA([]);
for It := 0 to wSobjDet.O['items'].AsArray.Length-1 do
FSobj.o[ID].A['items'].add(wSobjDet.O['items'].AsArray[it]);
end;
end;
end;
end;
wSobjDet.O['items'].AsArray.Length = 20 (each record in the array has a different type - string, object, integer...)
Newly created FSObj gets only empty array 'items' - length=0 (checked via txt)
What am I doing wrong?
(I've shortened and edited the code to make it more readable, but the procedure - going through the existing fields record by record and assigning them to the new one - is in the code.)