this.“var name”.item --> how to replace with a var (json)

xhebe

New Member
I have a json source. the logic is:\[code\]{"keyword":[ {"@attributes":{"id":"car"}, "top":{"@attributes":{"id":"car-top"},"assets":[{"@attributes":{"id":"car-top-ES"},"asset":[{ ............... *here is the data i need*.................}]}]}, "last":{"@attributes":{"id":"car-last"},"assets":[{"@attributes":{"id":"car-last-ES"},"asset":[{ ............... *here is the data i need*......}]}]}}]}\[/code\]As you can see, I have the data within top and last. In xml it is pretty easy to go over these and run through the whole code to find some elements, e.g. eventID which is in the data part.XML:\[code\]$(xml).find('asset').each(function(){\[/code\]in json I use:\[code\]$.ajax({dataType: 'jsonp',jsonp: 'callback',url: 'http://www.xxxxxxxx.com/test/soap.php',success: function (data) { $.each(data, function() { $.each(this, function() { var keyword = this["@attributes"].id; $.each(this.top.assets, function() {\[/code\]and here is my problem:$.each(this.top.assets, function() {How can I go over all data elements to check for an id? I dont want to go through top first, and then make a new each function, and run through the last array! I want to do it like the xml example - run over all data which are in the asset tree!thanks in advancebest,adrian
 
Back
Top