Loop through JSON data Associatively

Posted by Abs on Stack Overflow See other posts from Stack Overflow or by Abs
Published on 2010-04-01T22:40:49Z Indexed on 2010/04/01 22:43 UTC
Read the original article Hit count: 298

Filed under:
|
|

Hello all,

How can I loop through this json data without referring to the data items by a number. I would like to use it as an associative array. I have this so far:

$.post('/controlpanel/search', { type: type, string: string }, function(data){

        $.each(data, function() {

            $.each(this, function(index, itemData) {

                       //alert(data.id) something like this
                       //currently returns undefined

            });

        });

   }, 'json');

Example Json Code:

[{"id":"1","title":"","link":"http:\/\/www.msn.com","date_added":"0000-00-00 00:00:00",
"privacy_type":"0","user_id":"8","field2":"","field3":"","bookmark_id":"70","tag":"clean"}]

Thanks all for any help

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript