admin 管理员组

文章数量: 1184232


2024年4月13日发(作者:bsd码转十进制计算器)

delphi解析Json格式

SuperObject 是开源的 Delphi 的 JSON 工具包,可生成 JSON

数据以及进行 JSON 解析。

unit Unit6;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Co

ntrols, Forms,

Dialogs, StdCtrls;

type

TForm6 = class(TForm)

Button1: TButton;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

end;

var

Form6: TForm6;

implementation

uses superobject;

{$R *.dfm}

{ TForm6 }

procedure 1Click(Sender: TObject);

var

vJson,vItem: ISuperObject;

begin

vJson := SO('{"classname":"初二一班","pupils":[{"name":"张三

","sex":"男"},{"name":"李四","sex":"女"}]}');

ShowMessage(vJson['classname'].AsString);

//开始遍历

for vItem in vJson['pupils'] do

begin

ShowMessage(vItem['name'].AsString);

showMessage(vItem['sex'].AsString);

end;

end;

end.

SuperObject 下载地址:


本文标签: 进行 解析 生成