{"id":5643,"date":"2023-02-23T14:42:56","date_gmt":"2023-02-23T06:42:56","guid":{"rendered":"https:\/\/blog.qdac.cc\/?p=5643"},"modified":"2023-02-24T10:11:31","modified_gmt":"2023-02-24T02:11:31","slug":"%e3%80%90%e6%95%99%e7%a8%8b%e3%80%91qjson-%e5%88%9b%e5%bb%ba%e6%a0%b9%e7%bb%93%e7%82%b9%e4%b8%ba%e6%95%b0%e7%bb%84%e7%9a%84-json-%e5%86%85%e5%ae%b9","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=5643","title":{"rendered":"\u3010\u6559\u7a0b\u3011QJSON \u521b\u5efa\u6839\u7ed3\u70b9\u4e3a\u6570\u7ec4\u7684 JSON \u5185\u5bb9"},"content":{"rendered":"\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cQJson\u521b\u5efa\u540e\u7684\u5b9e\u4f8b\u662f jdtNull \u7c7b\u578b\uff08\u7a7a\u7c7b\u578b\uff09\uff0c\u5f53\u5411\u5176\u6dfb\u52a0\u5b50\u5143\u7d20\uff0c\u4f1a\u81ea\u52a8\u8c03\u6574\u4e3a jdtObject \uff08\u5bf9\u8c61\u7c7b\u578b\uff09\uff0c\u5982\u679c\u662f\u7528 AsXXX\u8d4b\u503c\u65f6\uff0c\u4f1a\u81ea\u52a8\u6839\u636e\u63a5\u53e3\u6539\u53d8\u7ed3\u70b9\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u5728 QJson \u4e2d\uff0c\u8981\u5c06\u6839\u7ed3\u70b9\u6539\u53d8\u6570\u7ec4\u7c7b\u578b\uff0c\u5c31\u9700\u8981\u660e\u786e\u6307\u5b9a\u8fd9\u4e00\u70b9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var\n   AJson:TQJson;\nbegin\n   AJson:=TQJson.Create;\/\/\u6216\u8005 AcquireJson\n   AJson.DataType:=jdtArray;\/\/\u660e\u786e\u6839\u7ed3\u70b9\u7c7b\u578b\u4e3aJSON\u6570\u7ec4<\/code><\/pre>\n\n\n\n<p>\u5728\u660e\u786e\u8fd9\u4e00\u70b9\u4ee5\u540e\uff0c\u540e\u9762\u7684\u4ee3\u7801\u5199\u6cd5\u5c31\u548c\u666e\u901a\u7684 JSON \u5bf9\u8c61\u4e00\u6837\u4e86\uff0c\u533a\u522b\u5728\u4e8e\u7531\u4e8e\u4e0d\u9700\u4f20 Key \u503c \uff0c\u76f4\u63a5\u8c03\u7528\u4e0d\u5e26\u53c2\u6570\u7684 Add \u51fd\u6570\u6765\u6dfb\u52a0\u5b50\u5143\u7d20\uff0c\u4e0b\u9762\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   AJson.Add.AsString:='123';\n   AJson.Add.AsInteger:=123;\n   with AJson.AddArray('') do\/\/\u56e0\u4e3a\u6839\u7ed3\u70b9\u662f\u6570\u7ec4\uff0c\u6240\u4ee5\u7ed9\u51fa\u540d\u79f0\u6ca1\u6709\u610f\u4e49\uff0c\u7f16\u7801\u65f6\u4f1a\u5ffd\u7565\n   begin\n      Add.AsFloat:=1.23;\n      Add.AsInteger:=23;\n   end;\n   with AJson.Add do\n   begin\n      Add('a1').AsString:='Object child';\n      Add('a2').AsInteger:=1234;\n   end;<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u6267\u884c\u540e\uff0c\u751f\u6210\u7684JSON\u7ed3\u6784\u5982\u4e0b \uff1a<\/p>\n\n\n\n<p>[&#8220;123&#8221;,123,[1.23,23],{&#8220;a1&#8243;:&#8221;object child&#8221;,&#8221;a2&#8243;:1234}]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cQJson\u521b\u5efa\u540e\u7684\u5b9e\u4f8b\u662f j [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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":[8],"tags":[],"class_list":["post-5643","post","type-post","status-publish","format-standard","hentry","category-delphi"],"views":1636,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5643","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5643"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5643\/revisions"}],"predecessor-version":[{"id":5647,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/5643\/revisions\/5647"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}