- changed status to resolved
Auto extracting from JSON list in the same parent JSON object
Issue #162
resolved
Run the following test code:
var Output:=JSON.NewObject;
Output.List:=JSON.Parse('[{"a":1,"b":5},{"a":2,"b":6}]');
WriteLn(Output.List.Length()); // writes "2"
Output.Single:=Output.List[0];
WriteLn(Output.List.Length()); // writes "1"
As you can see, when an element of the JSON list is assigned to another field of the same JSON object that contains the same list, the assigned element is extracted and removed from the list. It seems more like a bug to me than a desired behavior. Am I wrong?
Comments (1)
-
repo owner - Log in to comment
At the moment JSONVariants are single-parented, so assigning one will re-parent it.
If you want to duplicate them, you can use the .Clone() method