程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi7下SuperObject的JSON使用方法,superobjectjson

Delphi7下SuperObject的JSON使用方法,superobjectjson

編輯:Delphi

Delphi7下SuperObject的JSON使用方法,superobjectjson


uses    superobject;

procedure TForm1.FormCreate(Sender: TObject);
var aJson: ISuperObject;
aSuperArray: TSuperArray;
   i:Integer;
begin
  {1、賦初值}  aJson:=SO('{"zoo":"塗磊動物園","animals":[{"name":"猴子","year":"12"},{"name":"老虎","year":"132"}]}');
  {2、讀值前,一定要先判斷是否存在}  if   aJson['animals']<> nil  then
       showmessage(  aJson['animals'].AsString );

  {3、多值的讀取} aSuperArray:= aJson['animals'].AsArray;
//多值 "animals":[{"name":"猴子","year":"12"},
 //               {"name":"老虎","year":"132"}]
   for i:=0 to  aSuperArray.Length-1 do
 memo1.Lines.Add(aSuperArray[i]['name'].AsString+aSuperArray[i]['year'].AsString);

   aJson:=SO('{"code":0,"data":{"area":"華東","area_id":"300000","city":"宜春市","city_id":"360900","country":"中國","country_id":"CN","county":"","county_id":"","ip":"59.62.201.110","isp":"電信","isp_id":"100017","region":"江西省","region_id":"360000"}}');
  {4、深層級的訪問}  if   aJson['data.country']<> nil  then
   showmessage(  aJson['data.country'].AsString );    // 中國
end;

SuperObject.pas下載

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved