In my JavaScript I have a JSON Object which I use as a parameter of a Java object. On the Java side I receive a jdk.nashorn.internal.scripts.JO4 but only the jdk.nashorn.internal.scripts.JO class exits. How can I access this JSON Object?
var test = {
"id": 10,
"Hello": "World",
"test": {
"Lorem" : "Ipsum",
"java" : true
}
}
m.call(test);
Try using ScriptObjectMirror:
public void call(ScriptObjectMirror obj) {
System.out.println(obj.get("Hello"));
}
See this article for more examples: http://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/
With some google searches i found a solution: On the Java side, I must use a java.util.Map. So I can parse this Map to an org.json.simple.JSONObject
public void call(Map map){
JSONObject json = new JSONObject(map); // convert map to an json Object
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With