{"id":4231,"date":"2016-09-15T16:21:56","date_gmt":"2016-09-15T08:21:56","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4231"},"modified":"2016-09-15T16:22:20","modified_gmt":"2016-09-15T08:22:20","slug":"%e6%b3%9b%e5%9e%8b%e6%95%b0%e7%bb%84%e6%b8%85%e7%a9%ba%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4231","title":{"rendered":"\u6cdb\u578b\u6570\u7ec4\u6e05\u7a7a\u6570\u636e"},"content":{"rendered":"<h3><span style=\"color: #ff0000\"><strong>\u6211\u4e00\u76f4\u90fd\u5728\u5bfb\u627e\u5404\u79cd\u4e1a\u52a1\u529f\u80fd\u7684\u6700\u7b80\u5355\u5199\u6cd5\uff0c\u7528\u51cf\u6cd5\u7684\u6a21\u5f0f\u6765\u5f00\u53d1\u8f6f\u4ef6\u3002\u5982\u679c\u6709\u6bd4\u6211\u7684\u5199\u6cd5\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u8bf7\u7559\u8a00\u544a\u77e5<\/strong><\/span><\/h3>\n<p>\u6211\u662f\u6000\u7591\u6cdb\u578b\u6570\u7ec4 setlength\u540e\u4f1a\u4e0d\u4f1a\u6e05\u96f6\uff0c\u5f04\u4e86\u4e2a\u5c0fdemo\uff0c\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u6211\u4f1a\u6709\u8fd9\u4e2a\u60f3\u6cd5\uff0c\u96be\u9053\u662f\u6211\u770b\u6570\u636e\u7ed3\u6784\u5165\u9b54\u4e86\uff0c\u8bb0\u5f97\u8bb0\u5f55\u6307\u9488\u9700\u8981\u53e6\u7c7b\u91ca\u653e\u95ee\u9898\u3002<\/p>\n<p>\u8bb0\u4e0d\u6e05\u4e86 \u8111\u888b\u5b8c\u86cb\u4e86 \u4e0ademo \uff0c\u4e8b\u5b9e\u8bc1\u660esetlength(xxx,0)\u8fd9\u6837\u6765\u6e05\u7a7a \u6cdb\u578b\u6570\u7ec4\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\uff0c\u4e0d\u4f1a\u6709\u5185\u5b58\u6cc4\u9732<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"https:\/\/img.alicdn.com\/imgextra\/i2\/41670659\/TB2CfZaXdfB11BjSspmXXctQVXa-41670659.gif\" alt=\"\" width=\"409\" height=\"454\" \/>\u3002<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:delphi decode:true \">unit Unit4;\r\n\r\ninterface\r\n\r\nuses\r\n  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,\r\n  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;\r\n\r\ntype\r\n  TForm4 = class(TForm)\r\n    btn1: TButton;\r\n    mmo1: TMemo;\r\n    procedure btn1Click(Sender: TObject);\r\n    procedure FormCreate(Sender: TObject);\r\n  private\r\n    { Private declarations }\r\n  public\r\n    { Public declarations }\r\n  end;\r\n\r\n  TPerson  = record\r\n    name: string;\r\n    age: Integer;\r\n  end;\r\n\r\nvar\r\n  Form4: TForm4;\r\n\r\nimplementation\r\n\r\n{$R *.dfm}\r\n\r\nuses qjson;\r\n\r\nprocedure TForm4.btn1Click(Sender: TObject);\r\nvar\r\n  MyQj: TQJson;\r\n  MyPersons: TArray&lt;TPerson&gt;;\r\n  I: Integer;\r\nbegin\r\n  MyQj := TQJson.Create;\r\n  try\r\n    mmo1.Lines.Clear;\r\n    \/\/\u5411\u6570\u7ec4\u6dfb\u52a0\u6570\u636e\r\n    for I := 0 to 2 do\r\n    begin\r\n      SetLength(MyPersons, Length(MyPersons) + 1);\r\n      MyPersons[High(MyPersons)].name := '\u5965\u5df4\u9a6c'+I.ToString;\r\n      MyPersons[High(MyPersons)].age := I;\r\n    end;\r\n\r\n    \/\/\u663e\u793a\u51fa\u6765\u770b\u770b\r\n    MyQj.FromRecord&lt;TArray&lt;TPerson&gt;&gt;(MyPersons);\r\n    mmo1.Lines.Add(MyQj.AsJson);\r\n    mmo1.Lines.Add(sLineBreak+'------------------'+sLineBreak);\r\n\r\n    \/\/\u6e05\u7a7a\u6cdb\u578b\u6570\u7ec4\r\n    SetLength(MyPersons, 0);\r\n\r\n    \/\/\u6e05\u7a7a\u540e\u518d\u663e\u793a\u51fa\u6765\u770b\u770b\r\n    MyQj.FromRecord&lt;TArray&lt;TPerson&gt;&gt;(MyPersons);\r\n    mmo1.Lines.Add(MyQj.AsJson);\r\n  finally\r\n    MyQj.Free;\r\n  end;\r\nend;\r\n\r\nprocedure TForm4.FormCreate(Sender: TObject);\r\nbegin\r\n  ReportMemoryLeaksOnShutdown := True;\r\nend;\r\n\r\nend.\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4e00\u76f4\u90fd\u5728\u5bfb\u627e\u5404\u79cd\u4e1a\u52a1\u529f\u80fd\u7684\u6700\u7b80\u5355\u5199\u6cd5\uff0c [&hellip;]<\/p>\n","protected":false},"author":117,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[],"class_list":["post-4231","post","type-post","status-publish","format-standard","hentry","category-qjson"],"views":4291,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/117"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4231"}],"version-history":[{"count":2,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4231\/revisions"}],"predecessor-version":[{"id":4233,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4231\/revisions\/4233"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}