Thank you very much nutron that worked just fine ;o)
On 30 Dec., 17:40, nutron <[email protected]> wrote: > var obj = {"d":[ > {"Id":1,"RoleName":"Master","AddDate":"10-08-2008 > 21:28:23","Active":false}, > {"Id":2,"RoleName":"Administrator","AddDate":"10-08-2008 > 23:46:13","Active":true}, > {"Id":3,"RoleName":"SuperUser","AddDate":"11-08-2008 > 09:41:49","Active":true}, > {"Id":4,"RoleName":"User","AddDate":"10-08-2008 > 23:16:44","Active":true} > ]}; > obj.d.each(function(item) { > var tr = new Element('tr')..etc > $each(item, function(value, key) { > new Element('td', {text: value}).inject(tr); > } > > }); > > On Tue, Dec 30, 2008 at 8:26 AM, tbela99 (via Nabble) < > [email protected]<ml-user%[email protected]> > > > > > wrote: > > > you don't have to use list.each > > > this is similar to for(var i = 0; ...) loop, but you iterate directly > > on the object property which should be faster than list.each. > > > On 30 déc, 16:37, tbela99 > > <bna...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2092914&i=0>> > > wrote: > > > for(prop in object) if(object.hasOwnProperty(prop)) { > > > > //alert(typeof object[prop]); > > > > } > > > > object.hasOwnProperty is true if the property is not inherited. > > > > that's all you need > > > > On 30 déc, 08:42, websam > > > <mar...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2092914&i=1>> > > wrote: > > > > > Hello, > > > > > I'm making a class to create a table and fill that table with data > > > > from JSON. But I can't find a way to loop throug my JSON object > > > > without hardcoding the key/value pair. > > > > > My JSON looks like this : > > > > > {"d":[ > > > > {"Id":1,"RoleName":"Master","AddDate":"10-08-2008 > > > > 21:28:23","Active":false}, > > > > {"Id":2,"RoleName":"Administrator","AddDate":"10-08-2008 > > > > 23:46:13","Active":true}, > > > > {"Id":3,"RoleName":"SuperUser","AddDate":"11-08-2008 > > > > 09:41:49","Active":true}, > > > > {"Id":4,"RoleName":"User","AddDate":"10-08-2008 > > > > 23:16:44","Active":true} > > > > ]} > > > > > How can I loop through this without knowing the key's Id, RoleName, > > > > ect. ? > > > > > /Websam > > > ------------------------------ > > View message @ > >http://n2.nabble.com/Loop-through-JSON-object---tp2091559p2092914.html > > To start a new topic under MooTools Users, email > > [email protected]<ml-node%[email protected]> > > To unsubscribe from MooTools Users, click here< (link removed) >. > > ----- > The MooTools Tutorial: http://www.mootorial.comwww.mootorial.com > Clientcide: http://www.clientcide.comwww.clientcide.com > -- > View this message in > context:http://n2.nabble.com/Loop-through-JSON-object---tp2091559p2092964.html > Sent from the MooTools Users mailing list archive at Nabble.com.
