We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Netscape Javascript JSObject library question.
Page Index Toggle Pages: 1
Netscape Javascript JSObject library question. (Read 359 times)
Netscape Javascript JSObject library question.
Feb 5th, 2009, 5:40am
 
How can I access objects and arrays from JavaScript -> Processing? (I need processing to be able to import data in the form of objects and arrays from JavaScript).

I can access DOM elements but not the properties of JavaScript objects.

Suppose I have

foo = {"one":1,"two":2};

defined globally in JavaScript, when when I try to access "foo" from Processing via the window "JSObject" by using getMember(String <name>), I get a reference to an "Object". But I can't figure out how to get to "one" and "two" from this object.

Can someone kindly post a working sample sketch please?

//This is a duplicate post from the library section. Sorry..
Re: Netscape Javascript JSObject library question.
Reply #1 - Feb 5th, 2009, 2:50pm
 
I haven't tried it yet (it is on my todo list...) but from a quick look at JSObject reference, I think you should do a foo.getMember("one") to get the value of the property "one".
If that's not what you want (or if it doesn't work), I can dig a bit more.
Re: Netscape Javascript JSObject library question.
Reply #2 - Feb 5th, 2009, 6:00pm
 
It doesn't work. It returns an object of type "Object" but it doesn't have the getMember() method on it.
Page Index Toggle Pages: 1