How to parse the JSON Date format from the below given json data using jquery? -


{ "2013\/02\/05":[                         {"id":"84eb13cfed01764d9c401219faa56d53","colour":"#000000","category":"custom"} ], } 

i have used jquery code given below.i trying access date '2013/02/05' , array elements id ,colour , category of date.

     $(document).ready(function(){       var output = $("#changebtn");       $("#data").click(function(){         $.getjson("json_data.json",function(jd){                var dates = jd.date;                alert(dates);                 });           }); 

the object returned associative array can access property follows:

$.getjson("json_data.json",function(jd){                var dates = jd["2013\/02\/05"][0].colour;                alert(dates);  }); 

js fiddle: http://jsfiddle.net/dlkfk/

on side note, pretty nasty object. i'm not sure why needs assign array date property. if have control on object refactor it. 1 thing should refactor common after array since make json invalid.

{     "2013/02/05": [         {             "id": "84eb13cfed01764d9c401219faa56d53",             "colour": "#000000",             "category": "custom"         }     ], //this comma invalid }  

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -