美文网首页
2018-09-28 delphixe10 json

2018-09-28 delphixe10 json

作者: netppp | 来源:发表于2018-09-28 12:17 被阅读0次
unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,system.json,Vcl.StdCtrls;

type
  TForm3 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var  Root:TJSONObject;
     i:integer;
     jsonstr:string;
begin

        jsonstr:='{"code":100,"state":"true","data":["hero","npc","pet"]}';
        Root:= TJSONObject.ParseJSONValue(Trim(jsonstr)) as TJSONObject;
         for i:=0 to Root.count-1 do
            begin
               memo1.lines.add(Root.Get(i).JsonString.toString + ' = ' + Root.Get(i).JsonValue.ToString);
            end;
        showmessage( root.GetValue('state').ToString);


end;

end.

相关文章

网友评论

      本文标题:2018-09-28 delphixe10 json

      本文链接:https://www.haomeiwen.com/subject/yhuuoftx.html