Delphi7下SuperObject的JSON使用方法

2018-06-17 18:57:34来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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和JSON查看软件下载

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:[教学] Log.d 日志调试查看(所有平台)

下一篇:[安裝] Ubuntu Server 初试