Reputation: 296
I have this code:
ScriptEngine INTERPRETER = new ScriptEngineManager().getEngineByName("js");
obj = INTERPRETER.eval("var obj = {a:1, b:2};");
So, from the java object obj how can i extract the 2 value form the js object?
Upvotes: 0
Views: 150
Reputation: 472
You can use something like this:
ScriptEngine INTERPRETER = new ScriptEngineManager().getEngineByName("js");
ScriptObjectMirror obj = (ScriptObjectMirror) INTERPRETER.eval("obj = {a:1, b:2};");
System.out.println(obj.get("b"));
Upvotes: 1