{"id":1589,"date":"2020-12-07T21:03:50","date_gmt":"2020-12-07T13:03:50","guid":{"rendered":"http:\/\/blog.infinity.idv.tw\/?p=1589"},"modified":"2020-12-07T21:03:50","modified_gmt":"2020-12-07T13:03:50","slug":"delphi%e4%bd%bf%e7%94%a8lkjson%e5%a4%9a%e5%b1%a4%e6%ac%a1%e4%b8%80%e8%88%ac%e5%8f%96%e5%80%bc%e8%88%87%e9%99%a3%e5%88%97%e5%8f%96%e5%80%bc%e7%af%84%e4%be%8b","status":"publish","type":"post","link":"http:\/\/blog.infinity.idv.tw\/?p=1589","title":{"rendered":"DELPHI\u4f7f\u7528lkJSON\u591a\u5c64\u6b21\u4e00\u822c\u53d6\u503c\u8207\u9663\u5217\u53d6\u503c\u7bc4\u4f8b"},"content":{"rendered":"<p><font size=\"3\">\u6587\u7ae0\u51fa\u8655     <br \/><\/font><a title=\"http:\/\/rakelitica.blogspot.com\/2012\/07\/using-lkjson-example-with-google-drive.html\" href=\"http:\/\/rakelitica.blogspot.com\/2012\/07\/using-lkjson-example-with-google-drive.html\"><font size=\"3\">http:\/\/rakelitica.blogspot.com\/2012\/07\/using-lkjson-example-with-google-drive.html<\/font><\/a><\/p>\n<p><font size=\"3\">JSON\u6587\u4ef6\u7bc4\u672c(\u53ef\u8cbc\u5230 <\/font><a title=\"https:\/\/jsoneditoronline.org\/#left=local.lapedo&amp;right=local.vaxeha\" href=\"https:\/\/jsoneditoronline.org\/#left=local.lapedo&amp;right=local.vaxeha\"><font size=\"3\">https:\/\/jsoneditoronline.org\/#left=local.lapedo&amp;right=local.vaxeha<\/font><\/a><font size=\"3\"> \u5e6b\u4f60\u7dda\u4e0a\u683c\u5f0f\u5316JSON\u6bd4\u8f03\u597d\u770b\u61c2)<\/font><\/p>\n<p><font size=\"3\">{     <br \/>&#160; &quot;kind&quot;: &quot;drive#fileList&quot;,      <br \/>&#160; &quot;etag&quot;: &quot;\\&quot;ia2FS23424234234ANFYAdsc1Tyua2KKA-HnMs\\&quot;&quot;,      <br \/>&#160; &quot;selfLink&quot;: &quot;<\/font><a href=\"https:\/\/www.googleapis.com\/drive\/v2\/files&quot;\"><font size=\"3\">https:\/\/www.googleapis.com\/drive\/v2\/files&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160; &quot;items&quot;: [      <br \/>&#160; {      <br \/>&#160;&#160; &quot;kind&quot;: &quot;drive#file&quot;,      <br \/>&#160;&#160; &quot;id&quot;: &quot;0BwtHRVB3TFRHVllvRVE&quot;,      <br \/>&#160;&#160; &quot;etag&quot;: &quot;\\&quot;ia2H5NSXK_wk\/MTM0MTc3MTMwMTU5Mg\\&quot;&quot;,      <br \/>&#160;&#160; &quot;selfLink&quot;: &quot;<\/font><a href=\"https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE&quot;\"><font size=\"3\">https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160;&#160; &quot;alternateLink&quot;: &quot;<\/font><a href=\"https:\/\/docs.google.com\/folder\/d\/0BwPgllvRVE\/edit&quot;\"><font size=\"3\">https:\/\/docs.google.com\/folder\/d\/0BwPgllvRVE\/edit&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160;&#160; &quot;permissionsLink&quot;: &quot;<\/font><a href=\"https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE\/permissions&quot;\"><font size=\"3\">https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE\/permissions&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160;&#160; &quot;title&quot;: &quot;Folder0&quot;,      <br \/>&#160;&#160; &quot;mimeType&quot;: &quot;application\/vnd.google-apps.folder&quot;,      <br \/>&#160;&#160; &quot;description&quot;: &quot;Folzer Zero&quot;,      <br \/>&#160;&#160; &quot;labels&quot;: {      <br \/>&#160;&#160;&#160; &quot;starred&quot;: false,      <br \/>&#160;&#160;&#160; &quot;hidden&quot;: false,      <br \/>&#160;&#160;&#160; &quot;trashed&quot;: false,      <br \/>&#160;&#160;&#160; &quot;restricted&quot;: false,      <br \/>&#160;&#160;&#160; &quot;viewed&quot;: true      <br \/>&#160;&#160; },      <br \/>&#160;&#160; &quot;createdDate&quot;: &quot;2012-07-08T18:13:51.185Z&quot;,      <br \/>&#160;&#160; &quot;modifiedDate&quot;: &quot;2012-07-08T18:15:01.592Z&quot;,      <br \/>&#160;&#160; &quot;modifiedByMeDate&quot;: &quot;2012-07-08T18:15:01.592Z&quot;,      <br \/>&#160;&#160; &quot;lastViewedByMeDate&quot;: &quot;2012-07-08T18:15:07.039Z&quot;,      <br \/>&#160;&#160; &quot;parents&quot;: [      <br \/>&#160;&#160;&#160;&#160; {      <br \/>&#160;&#160;&#160;&#160; &quot;kind&quot;: &quot;drive#parentReference&quot;,      <br \/>&#160;&#160;&#160;&#160; &quot;id&quot;: &quot;0AAPgHUk9PVA&quot;,      <br \/>&#160;&#160;&#160;&#160; &quot;selfLink&quot;: &quot;<\/font><a href=\"https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE1\/parents\/0AA6_KcYtHUk9PVA&quot;\"><font size=\"3\">https:\/\/www.googleapis.com\/drive\/v2\/files\/0BwPgllvRVE1\/parents\/0AA6_KcYtHUk9PVA&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160;&#160;&#160;&#160; &quot;parentLink&quot;: &quot;<\/font><a href=\"https:\/\/www.googleapis.com\/drive\/v2\/files\/0AA6_KcYtHUk9PVA&quot;\"><font size=\"3\">https:\/\/www.googleapis.com\/drive\/v2\/files\/0AA6_KcYtHUk9PVA&quot;<\/font><\/a><font size=\"3\">,     <br \/>&#160;&#160;&#160;&#160; &quot;isRoot&quot;: true      <br \/>&#160;&#160;&#160; }      <br \/>&#160;&#160; ],      <br \/>&#160;&#160; &quot;userPermission&quot;: {      <br \/>&#160;&#160;&#160; &quot;kind&quot;: &quot;drive#permission&quot;,      <br \/>&#160;&#160;&#160; &quot;etag&quot;: &quot;\\&quot;ia2FSHMEjvcFQvtI4rH3hoJimnEgfM\\&quot;&quot;,      <br \/>&#160;&#160;&#160; &quot;id&quot;: &quot;current&quot;,      <br \/>&#160;&#160;&#160; &quot;role&quot;: &quot;owner&quot;,      <br \/>&#160;&#160;&#160; &quot;type&quot;: &quot;user&quot;      <br \/>&#160;&#160; },      <br \/>&#160;&#160; &quot;quotaBytesUsed&quot;: &quot;0&quot;,      <br \/>&#160;&#160; &quot;ownerNames&quot;: [      <br \/>&#160;&#160;&#160; &quot;Artur&quot;      <br \/>&#160;&#160; ],      <br \/>&#160;&#160; &quot;lastModifyingUserName&quot;: &quot;Artur&quot;,      <br \/>&#160;&#160; &quot;editable&quot;: true,      <br \/>&#160;&#160; &quot;writersCanShare&quot;: true      <br \/>&#160; },      <br \/>&#160; {      <br \/>&#160;&#160; &quot;kind&quot;: &quot;drive#file&quot;,      <br \/>&#160; }      <br \/>&#160; {      <br \/>&#160;&#160; &quot;kind&quot;: &quot;drive#file&quot;,      <br \/>&#160; }      <br \/>&#160; ]      <br \/> }<\/font><\/p>\n<p><font size=\"3\"><\/font><\/p>\n<p><font size=\"3\">DELPHI JSON lkJSON \u7a0b\u5f0f\u7bc4\u4f8b<\/font><\/p>\n<p><font size=\"3\">procedure TForm1.BlaBlaBla( JSonString : string );     <br \/> var      <br \/>&#160; js,      <br \/>&#160; itjs: TlkJSONobject;<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; ii&#160; : integer;     <br \/>&#160; Str : string;<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; Trash : boolean;     <br \/> begin<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; \/\/ Parse the String     <br \/>&#160; js := TlkJSON.ParseText( JSonString ) as TlkJsonObject;<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; \/\/ Values on the first level are as easy as this     <br \/>&#160; selfLink := js.getString( &#8216;selfLink&#8217; );<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; \/\/ let&#8217;s digg into each document &#8230;     <br \/>&#160; for ii:=0 to js.Field[&#8216;items&#8217;].Count-1 do      <br \/>&#160;&#160;&#160; begin<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160;&#160;&#160; \/\/ each document is a TlkJSONobject &#8230;     <br \/>&#160;&#160;&#160; ijs := (js.Field[&#8216;items&#8217;].Child[ ii ] as TlkJSONobject);<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160;&#160;&#160; \/\/ So, it will be so simple to get something like this&#8230;     <br \/>&#160;&#160;&#160; Item.etag&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; := ijs.getString( &#8216;etag&#8217; );      <br \/>&#160;&#160;&#160; Item.Id&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; := ijs.getString( &#8216;id&#8217; );      <br \/>&#160;&#160;&#160; Item.title&#160;&#160;&#160;&#160;&#160;&#160;&#160; := ijs.getString( &#8216;title&#8217; );      <br \/>&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160; \/\/ Or a little bit different&#8230;&#160;&#160;&#160; <br \/>&#160;&#160;&#160; Item.IsTrash&#160;&#160;&#160;&#160;&#160; := ijs[&#8216;labels&#8217;].Field[&#8216;trashed&#8217;].Value;<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160;&#160;&#160; end;<\/font><\/p>\n<p> <font size=\"3\"><\/font>  <\/p>\n<p><font size=\"3\">&#160; js.Free;     <br \/> end<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u51fa\u8655     http:\/\/rakelitica.blogspot.com\/2012\/07\/using-lkjson-example-with-google-drive.html<\/p>\n<p>JSON\u6587\u4ef6\u7bc4\u672c(\u53ef\u8cbc\u5230 https:\/\/jsoneditoronline.org\/#left=local.lapedo&amp;right=local.vaxeha \u5e6b\u4f60\u7dda\u4e0a\u683c\u5f0f\u5316JSON\u6bd4\u8f03\u597d\u770b\u61c2)<\/p>\n<p>{     &#160; &quot;kind&quot;: &quot;drive#fileList&quot;,      &#160; &quot;etag&quot;: &quot;\\&quot;ia2FS23424234234ANFYAdsc1Tyua2KKA-HnMs\\&quot;&quot;,      &#160; &quot;selfLink&quot;: &quot;https:\/\/www.googleapis.com\/drive\/v2\/files&quot;,     &#160; &quot;items&quot;: [      &#160; {      &#160;&#160; &quot;kind&quot;: &quot;drive#file&quot;,   [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[653],"_links":{"self":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1589"}],"collection":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1589"}],"version-history":[{"count":1,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1589\/revisions"}],"predecessor-version":[{"id":1590,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1589\/revisions\/1590"}],"wp:attachment":[{"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1589"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.infinity.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}