{"id":583,"date":"2009-12-22T13:57:39","date_gmt":"2009-12-22T12:57:39","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=583"},"modified":"2010-01-30T12:24:53","modified_gmt":"2010-01-30T11:24:53","slug":"parsing-json-array-using-ulkjson","status":"publish","type":"post","link":"https:\/\/sickel.net\/blogg\/?p=583","title":{"rendered":"Parsing json array using uLkjson"},"content":{"rendered":"<p>Back into delphi7&#8230;<\/p>\n<p>Needing to transfer some data over the net from a server to my delphi application, it seemed like a good idea to use JSON and according to <a href=\"http:\/\/json.org\">json.org<\/a> there are no less than three libraries for parsing json in delphi. The first one <a href=\"https:\/\/sourceforge.net\/projects\/is-webstart\/\">webstart \/ Delphi web utils<\/a> looked pretty good, but all documentation and examples was in Spanish&#8230; Well, learning Spanish is no bad plan, but not today. <\/p>\n<p>The next one, <a href=\"http:\/\/sourceforge.net\/projects\/lkjson\">JSON Delphi Library, uLkJSON<\/a> seemed a bit more simple. No documentation but a few examples &#8211; of which none covered arrays which I needed to use&#8230;<\/p>\n<p>At last, <a href=\"http:\/\/www.progdigy.com\/?page_id=6\">JSON superobject<\/a> seemed to have everything, but didn&#8217;t compile under delphi 7. <\/p>\n<p>Well, then, use the source, Luke,<\/p>\n<p>Digging through the source of uLkJSON, i managed at least to dig information out of the arrays I had put up. Having a form with a Memo named Memo1, this lists the names and values of the arrays into the Memo:<\/p>\n<pre>\r\nprocedure listarray(returnval: string);\r\nvar\r\n  systems : TStrings;\r\n  returnval: string;\r\n  json,item:TlkJSONbase;\r\n  i,j: integer;\r\n  list: TlkJSONObject;\r\nbegin\r\n  json:= TlkJSON.ParseText(returnval);\r\n  for i:=0 to pred(json.Count) do begin\r\n    item:=TlkJSONObject(json).child[i]; \r\n\/\/ This is the named array, name in name, the array in Objvalue\r\n    Memo1.Lines.Add(TlkJSONobjectmethod(item).Name);\r\n    list:=TlkJSONobject(TlkJSONobjectmethod(item).Objvalue);\r\n{   list is the array it self. This may be too much jiggling back and forth between object types, but at least it works...}\r\n    for j := 0 to pred(TlkJSONobject(list).count) do\r\n      Memo1.Lines.add('->'+tlkJSONlist(list).Child[j].Value);\r\n    end;\r\n  end;\r\nend;\r\n<\/pre>\n<p>Not too hard, &#8212; if it just had been some documentation or an example on this, that would have saved me a day. Hopefully this saves a day for someone else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Back into delphi7&#8230; Needing to transfer some data over the net from a server to my delphi application, it seemed like a good idea to use JSON and according to json.org there are no less than three libraries for parsing &hellip; <a href=\"https:\/\/sickel.net\/blogg\/?p=583\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4],"tags":[],"class_list":["post-583","post","type-post","status-publish","format-standard","hentry","category-data"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-9p","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=583"}],"version-history":[{"count":4,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/583\/revisions\/678"}],"wp:attachment":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}