{"id":159,"date":"2009-06-29T11:51:54","date_gmt":"2009-06-29T16:51:54","guid":{"rendered":"http:\/\/hoolihan.net\/blog-tim\/?p=159"},"modified":"2009-06-29T15:13:05","modified_gmt":"2009-06-29T20:13:05","slug":"json-objects","status":"publish","type":"post","link":"http:\/\/hoolihan.net\/blog-tim\/2009\/06\/29\/json-objects\/","title":{"rendered":"JSON Objects"},"content":{"rendered":"<p>Answered a <a title=\"a question on Stack Overflow\" href=\"http:\/\/stackoverflow.com\/questions\/1059207\/getting-invalid-string-around-my-json-outputted-from-using-the-javascriptseri\/1059246#1059246\">question on StackOverflow <\/a>that I thought is worth posting about.\u00a0 It&#8217;s surprising how many people try to work with JSON without knowing\u00a0 javascript.<\/p>\n<p>Most JSON either returns objects {} or arrays [].\u00a0 The first thing you learn about JSON is that you can just eval the object.  In the case of arrays, you have to remember deal with them as such.\u00a0 For example&#8230;<\/p>\n<pre>\r\n    $(document).ready(function(){\r\n       var a = eval(\"[1,2,3]\");\r\n       for(var i in a) {\r\n        $(\"#results\").append(a[i]);\r\n       }\r\n    });\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Answered a question on StackOverflow that I thought is worth posting about.\u00a0 It&#8217;s surprising how many people try to work with JSON without knowing\u00a0 javascript. Most JSON either returns objects {} or arrays [].\u00a0 The first thing you learn about JSON is that you can just eval the object. In the case of arrays, you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,18,24],"tags":[77,69],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-aspnet","category-programming","category-web","tag-json","tag-linkedin"],"_links":{"self":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":0,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"wp:attachment":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}