Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-12

How to insert item in TJSONObject?

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

To Add or Delete is very easy:

TJSONObject(FJSONData).Add('Item name', 'Item value');
TJSONObject(FJSONData).Delete(AIndex);

And to Insert?

TJSONObject(FJSONData).Insert(AIndex, 'Item name', 'Item value')? No no no... TJSONObject don't implements the method Insert (or Move method). :(

Thx.

Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> Facebook - <facebook.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

Unknown author
to silvioprog
silvioprog wrote 13 lines
Hello, To Add or Delete is very easy: TJSONObject(FJSONData).Add('Item name', 'Item value'); TJSONObject(FJSONData).Delete(AIndex); And to Insert? TJSONObject(FJSONData).Insert(AIndex, 'Item name', 'Item value')? No no no... TJSONObject don't implements the method Insert (or Move method). :(

The order of elements in a json object is irrelevant.

You should never rely on that. So just add at the end.

Michael.

Reply by email

silvioprog
to Unknown author

2011/12/12 :
[...]

The order of elements in a json object is irrelevant. You should never rely on that. So just add at the end.

I'm using JSON with ComboBox/ListBox/CheckListBox, and these components have the methods Move/Insert. :/

But I'll try to solve this problem in a different way. Thank you Michael! :)

Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> Facebook - <facebook.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

Artur Stuczynski
to silvioprog

W dniu 2011-12-12 19:44, silvioprog pisze:

I'm using JSON with ComboBox/ListBox/CheckListBox, and these components have the methods Move/Insert. :/

Doesn't JSON support arrays? I think you should take a

Reply by email

Michael Van Canneyt
to silvioprog: 2011/12/12 : [...] I'm using JSON with ComboBox/ListBox/CheckListBox, and these…
silvioprog wrote 10 lines
2011/12/12 : [...] > The order of elements in a json object is irrelevant. > > You should never rely on that. So just add at the end. I'm using JSON with ComboBox/ListBox/CheckListBox, and these components have the methods Move/Insert. :/ But I'll try to solve this problem in a different way. Thank you Michael! :)

You should try an TJSONArray then, not a TJSONObject ?

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

Hello,

I'll try it with JSONArray later on. Thank you, guys! ;)

Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> Facebook - <facebook.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email