zoukankan      html  css  js  c++  java
  • Delphi Qjson

    使用QJSON解析数据:

     JSon 字符串:

    {"Code":1,"Msg":"",
    "Data":[{"NetType":"电信","ServerName":"test1","ServerAddr":"127.0.0.1:30001","ServerIp":"55551","ServerPort":3000,"OnlineCount":300,"MaxOnlineCount":0},{"NetType":"电信","ServerName":"test1","ServerAddr":"::13000","ServerIp":"::1","ServerPort":3000,"OnlineCount":3,"MaxOnlineCount":0},{"NetType":"电信","ServerName":"test1","ServerAddr":"127.0.0.1:3000","ServerIp":"::1","ServerPort":3000,"OnlineCount":3,"MaxOnlineCount":0}]}
    View Code

    Delphi代码:

    procedure TForm2.Button1Click(Sender: TObject);
    var
      Json,AItem:TQJson;
      i:Integer;
    
    begin
        Json:=TQJson.Create;
        Json.Parse(Memo1.Text);
        //ShowMessage(Json.AsString);
    
        AItem := Json.ItemByName('Data') ;
        for I := 0 to AItem.Count-1 do
        begin
          Memo2.Lines.Add(AItem.Items[i].ValueByName('NetType',''));
          Memo2.Lines.Add(AItem.Items[i].ValueByName('ServerAddr',''));
          Memo2.Lines.Add(AItem.Items[i].ValueByName('ServerIp',''));
          Memo2.Lines.Add(AItem.Items[i].ValueByName('ServerPort',''));
          Memo2.Lines.Add(AItem.Items[i].ValueByName('OnlineCount',''));
          Memo2.Lines.Add(AItem.Items[i].ValueByName('MaxOnlineCount',''));
          Memo2.Lines.Add('-----------------------------------------')
        end;
    end;
    View Code

    其它例子:

    1.http://www.cnblogs.com/codingnote/p/3821025.html?utm_source=tuicool&utm_medium=referral

  • 相关阅读:
    Django中实现加载渲染模版
    【干货】批量文件合拼 cat 命令的使用
    【Sql】获取数据库字段信息
    【C#】 TxtHelper
    【Css】鼠标
    【HTTP】H5唤醒支付宝
    【dotnet】程序集注入
    【OpenXml】excel 导入导出
    一、API​​网关
    【kafka】二、kafka的基本概念
  • 原文地址:https://www.cnblogs.com/stroll/p/5263867.html
Copyright © 2011-2022 走看看