Possible Duplicate:
Convert a JSON string to object in Java?
I'm working on a scripting implementation for a video game written in Java.
I'm interested in being able to define a javascript object such as:
var obj = ({
x: 1,
a: "meh",
onEvent: function(info) {
//do stuff
}
});
and passing it through a determined pipeline into Java land. Currently, in Java I'm receiving the object as a sun.org.mozilla.javasript.internal.NativeObject which doesn't look very usable . Is there any way I can transfer the javascript into a Java object where I can access the data within? Specifically, without using GWT, as I'm not really working with web technologies.
EDIT FOR CLARITY: I'm not passing in a string of Javascript code to the Java function ala JSON. I'm using the javax.script package to evaluate entire scripts. Within the script engine there are bindings to Java objects with methods I'd like to pass in my javascript object as a parameter.
thanks in advance!