{"id":232,"date":"2017-03-23T10:59:52","date_gmt":"2017-03-23T10:59:52","guid":{"rendered":"http:\/\/codeinsightacademy.com\/blog\/?p=232"},"modified":"2017-05-12T05:20:03","modified_gmt":"2017-05-12T05:20:03","slug":"working-with-json","status":"publish","type":"post","link":"https:\/\/codeinsightacademy.com\/blog\/angular-js\/working-with-json\/","title":{"rendered":"Working with JSON"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta CHARSET=\"UTF-8\"&gt;\r\n        &lt;script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body ng-app=\"myApp\" ng-controller=\"myCtrl\"&gt;\r\n        &lt;h2&gt;JSON&lt;\/h2&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                String\r\n            &lt;\/legend&gt;\r\n            &lt;div ng-init='name = {\"first_name\":\"Shailesh\", \"last_name\" : \"Sonare\"}'&gt;\r\n                {{name.first_name}} &lt;br\/&gt;\r\n                {{name.last_name}}\r\n            &lt;\/div&gt;\r\n        &lt;\/fieldset&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                Numbers\r\n            &lt;\/legend&gt;\r\n            &lt;div ng-init='months = {\"jan\": 1, \"feb\" : 2}'&gt;\r\n                {{months.jan}} &lt;br\/&gt;\r\n                {{months.feb}}\r\n            &lt;\/div&gt;\r\n        &lt;\/fieldset&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                Objecs\r\n            &lt;\/legend&gt;\r\n            &lt;div ng-init='result = {employee:{\"name\": \"Shailesh\", \"age\" : 28}}'&gt;\r\n                {{result.employee.name}} &lt;br\/&gt;\r\n                {{result.employee.age}}\r\n            &lt;\/div&gt;\r\n        &lt;\/fieldset&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                Array\r\n            &lt;\/legend&gt;\r\n            &lt;div ng-init='result = {employee:[{\"name\": \"Shailesh\", \"age\" : 28},{\"name\": \"Mahesh\", \"age\" : 26}]}'&gt;\r\n                {{result.employee[0].name}} &lt;br\/&gt;\r\n                {{result.employee[1].age}}\r\n            &lt;\/div&gt;\r\n            &lt;div ng-init='result2 = {months:[\"Jan\",\"Feb\"]}'&gt;\r\n                {{result2.months[0]}} &lt;br\/&gt;\r\n                {{result2.months[1]}}\r\n            &lt;\/div&gt;\r\n        &lt;\/fieldset&gt;\r\n    &lt;\/body&gt;\r\n    &lt;script&gt;\r\n        var app = angular.module(\"myApp\", []);\r\n        app.controller(\"myCtrl\", function($scope) {\r\n\r\n        });\r\n    &lt;\/script&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &lt;DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta CHARSET=&#8221;UTF-8&#8243;&gt; &lt;script src=&#8221;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js&#8221;&gt;&lt;\/script&gt; &lt;\/head&gt; &lt;body ng-app=&#8221;myApp&#8221; ng-controller=&#8221;myCtrl&#8221;&gt; &lt;h2&gt;JSON&lt;\/h2&gt; &lt;fieldset&gt; &lt;legend&gt; String &lt;\/legend&gt; &lt;div ng-init=&#8217;name = {&#8220;first_name&#8221;:&#8221;Shailesh&#8221;, &#8220;last_name&#8221; : &#8220;Sonare&#8221;}&#8217;&gt; {{name.first_name}} &lt;br\/&gt; {{name.last_name}} &lt;\/div&gt; &lt;\/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt; Numbers &lt;\/legend&gt; &lt;div ng-init=&#8217;months = {&#8220;jan&#8221;: 1, &#8220;feb&#8221; : 2}&#8217;&gt; {{months.jan}} &lt;br\/&gt; {{months.feb}} &lt;\/div&gt; &lt;\/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt; Objecs &lt;\/legend&gt; &lt;div ng-init=&#8217;result = {employee:{&#8220;name&#8221;: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/232"}],"collection":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/comments?post=232"}],"version-history":[{"count":2,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/232\/revisions"}],"predecessor-version":[{"id":255,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/232\/revisions\/255"}],"wp:attachment":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/media?parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/categories?post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/tags?post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}