Delphi 将对象转换为JSON字符串或TJSONObject

2022-11-30 16:25:53 作者:admin

本文整理自网络,侵删。

 type  TPerson = record  private    FAge: Integer;    FName: string;  public    property Name: string read FName write FName;    property Age: Integer read FAge write FAge;  end;
uses  System.Generics.Collections,  REST.Json;
procedure TForm1.Button1Click(Sender: TObject);var  Alice, Bob: TPerson;  People: TList<TPerson>;  S: string;begin  People := TList<TPerson>.Create;
  Alice.Name := 'Alice';  Alice.Age := 20;  People.Add(Alice);  Bob.Name := 'Bob';  Bob.Age := 30;  People.Add(Bob);
  S := TJson.ObjectToJsonString(People);  Memo1.Text := S;end;

相关阅读 >>

Delphi+mysql:tadoquery使用插入中文乱码解决方法

Delphi 使用zlib对datasetprovider.data数据包进行压缩传输的测试

Delphi 图像灰度化处理

Delphi idhttpserver实现webservice

Delphi 利用sendinput模拟鼠标键盘

Delphi 双击隐藏tabsheet

Delphi整理三(窗体和基本组件)

为什么编程是独一无二的职业

Delphi 用idhttp打开网页或下载文件时如何显示进度

Delphi-dbgrid取得所有表中的值

更多相关阅读请进入《Delphi》频道 >>



在线咨询 拨打电话