Listbox with JSON data - Delphi mobile

Asked

Viewed 469 times

0

I have that data JSON that returns from a webservice query:

[{
    "id":"1",
    "usuario":"teste",
    "senha":"teste",
    "chave":"d59876jh",
    "email":"[email protected]"
}]

I need to populate the Items of a ListBox with them.

Someone knows how to do?

  • Just so I understand better, you are consuming the data of a Webservice, need to popular the Listbox on Mobile with the return of data from Webservice, you have already made the mobile connection via Webservice?... if yes, I suggest searching for Restclient, Restresponse and Restrequest which are the components to receive this data.

  • @Jeffersonrudolf I am using only an Idhttp that makes a query via GET and returns this JSON because this way I do not use REST only the return of a URL passed by the component because my webservice is php mysql hosted normally as a website.

  • First step is to find a Framework to serialize/deserialize JSON: I suggest https://bitbucket.org/soundvibe/delphi-oop/src. Once you’ve decided on one, we follow up with the examples.

  • @Victorzanella I have already created the php webservice it responds right the way I put the JSON above. I tested in a Tmemo and everything straight with the pairs etc. I’m picking up in the easiest part theoretically that would be popular the listbox with the data obtained.

  • What I meant was, it’s easier for you to find a lib to read JSON in Delphi. It’s much easier to get JSON deserialized in a list of objects, and work with it, than to walk around a string.

  • In that case, if you ever need to send something from the app to your webapp, it will make it easier too. If you agree, I can set an example with lib

  • @Ezequieltavares, managed to solve?

  • @Jeffersonrudolf ended up abandoning Delphi for mobile applications I’m using PHONEGAP that swept me with the extreme simplicity of developing mobile. hug

Show 3 more comments

1 answer

-1

If you have the return of the data, I will put an example of how popular a Listbox, but I realized that it has several user data for example, it was not better to use Listview?...

var
  i: Integer;
  oListBoxItem: TListBoxItem;
begin
  ListBox1.BeginUpdate;
  for i := 0 to 5-1 do
  begin
    oListBoxItem := TListBoxItem.Create(ListBox1);
    oListBoxItem.Text := 'Stack';
    oListBoxItem.ItemData.Accessory := TListBoxItemData.TAccessory(1);
    ListBox1.AddObject(oListBoxItem);
  end;
  ListBox1.EndUpdate;
end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.