Reputation: 47
Do I need to free a JSONArray or TJSONObject even if it is added to another TJSONObject ?
Code example:
var DocHead: TJSONObject;
DocLines: TJSONArray;
...
While not Dataset1.EOF DO
Begin
DocLines := TJSONArray.Create();
//Code that Fills the DocLines array
DocHead.AddPair('DocumentLines',DocLines);
Dataset1.next;
End;
...
I use Delphi 10.3.3 RIO
Thanks in advance
Upvotes: 0
Views: 1580
Reputation: 28516
Whether or not you need to free JSONArray
or JSONObject
depends on its Owned
property, which is set to True
by default when you construct the instance. If you don't change that value, then you don't need to free object that is added to another JSON object.
However, if you don't add the object to another JSON object then you still need to manually free instance you have created.
Upvotes: 8