im new to JSON and php and IOS development using Delphi XE2.
i want to parse a JSON array which i get from the php script
http://returnjson.ap01.aws.af.cm/returnjson.php
when this is opened i get the array as
[{"cname":"MAAO"},{"cname":"MAIM"}]
i have installed this parser from http://arcana.sivv.com/chimera
and a code sample is here
procedure TForm1.Button3Click(Sender: TObject);
var
i : integer;
obj : IJSONObject;
begin
obj := JSON('{"firstname":"leonard",'+
' "lastname":"nimoy",'+
' "email":['+
' "spock@enterprise.com",'+
' "lazydude@mars.com"]'+
'}');
Writeln(obj['firstname']);
for i := 0 to obj.Arrays['email'].count-1 do
begin
Writeln(obj.Arrays['email'][i]);
// StringGrid1.Cells[0,i]:=obj.Arrays['email'][i];
end;
obj['lastname'] := 'shatner';
writeln(obj.AsJSON);
ReadLn;
end;
can any one tell me how to pass the json array from the
http://returnjson.ap01.aws.af.cm/returnjson.php
to obj : IJSONObject; ?
You would need to use some way of obtaining the data from the webserver. I use TMS web software components. I do not use XE2 so not sure if there is a native component to do this.
I used their webdata component to do something similar. Drop a webdata component on the form and then the code from the examples:-