[jQuery] Re: Accessing a JSON property from an unknown variable?

2009-02-14 Thread seasoup
It's not really an associative array. It is the property of an object, there are two notations for getting at an objects properties: foo.bar and foo['bar'] though you could even: eval('foo.' + fooProp); foo.bar is the preferred method, but if the property name has a space in it or needs to

[jQuery] Re: Accessing a JSON property from an unknown variable?

2009-02-13 Thread James
alert( foo[fooProp] ); On Feb 13, 2:05 pm, Nic adaptive...@gmail.com wrote: For instance, var foo = { bar: barVal, baz: bazVal } var fooProp = bar; How can I access barVal through fooProp? I know this isn't exactly jQuery group discussion but I figured since it was part of a jQuery

[jQuery] Re: Accessing a JSON property from an unknown variable?

2009-02-13 Thread Josh Nathanson
foo[fooProp] // returns barVal Is that what you mean? -- Josh -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Nic Sent: Friday, February 13, 2009 4:06 PM To: jQuery (English) Subject: [jQuery] Accessing a JSON property from an

[jQuery] Re: Accessing a JSON property from an unknown variable?

2009-02-13 Thread Nic Luciano
Oh wow, I didn't realize JSON would act like an associative array in that way... Thanks guys! On Fri, Feb 13, 2009 at 7:10 PM, Josh Nathanson joshnathan...@gmail.comwrote: foo[fooProp] // returns barVal Is that what you mean? -- Josh -Original Message- From: