Returning Array or JSON object

Mar 8, 2010 at 1:46 AM

I've been trying to return an array or JSON object, but fail to do so. The object returned is always null.

I am using the stable release from the downloads, and the Javascript code is loaded successfully from an external file (using FileStream).

Here's a part of my code:

String s = "var message = [\"testing1\", \"testing2\"]; return message";
var o = jsEngine.Run(s);
String[] messages = (String[])o;

 

 

Mar 8, 2010 at 7:43 AM

Have you tried *NOT* using "return"?:

var message = [\"testing1\", \"testing2\"]; message;

or

[\"testing1\", \"testing2\"];
Mar 8, 2010 at 1:31 PM
GWBasic wrote:

Have you tried *NOT* using "return"?:

var message = [\"testing1\", \"testing2\"]; message;

or

[\"testing1\", \"testing2\"];

Hi GWBasic

I've tried variations of it. Not working. The example I gave should work because it is directly modified from the examples from the homepage. Return a string or number does good, but not an array.

Cheers

Sam

 

Mar 8, 2010 at 2:03 PM

Check this:

http://jint.codeplex.com/Thread/View.aspx?ThreadId=79294

Jorge

 

Mar 9, 2010 at 4:04 PM
jorgeleo wrote:

Check this:

http://jint.codeplex.com/Thread/View.aspx?ThreadId=79294

Jorge

 

Hey Jorge

Thanks! That's some solution I've been looking for!

 

Cheers

Sam Yong