Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Array to exsisting Json #129

Open
IronGarlic opened this issue Sep 12, 2018 · 3 comments
Open

Add Array to exsisting Json #129

IronGarlic opened this issue Sep 12, 2018 · 3 comments

Comments

@IronGarlic
Copy link

Hi,
i have a JSON like this
{
"Details":""
}

I want add an array to "Details", but i can't find an example to do that.

@vkrapotkin
Copy link
Contributor

vkrapotkin commented Sep 12, 2018

X:=TSuperObject.Create(JsonString);
item := TSuperObject.Create();
item.S['aaa'] := 'aaaaa';
item.I['bbb'] := 12345;
X.A['Details'].Add(item);

I guess you want to "Details" TO BE an array
so you'll get
{ "Details":[{"aaa":"aaaaa", "bbb":12345}] }

@IronGarlic
Copy link
Author

hi,
thanks for the quick response, btw how can i re-use the item?
Because there is not .clear .free or wat to destroy the object?

@vkrapotkin
Copy link
Contributor

vkrapotkin commented Sep 13, 2018

nono!
you've attached this to array and it'll be freed after use becuase it's an interface!
Arr:ISuperArray;
Item, X:ISuperObject;
instead you simply have to create a new item every time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants