title: Passing json data from javascript to Java
body: <p>I'm trying to pass json data from javascript to java, like below. The idea is to pass the data to the java code as a javascript object (and not a a string which I know can be done ). I've tried the code below without success - idea was to use NativeJson.stringify to convert from a javascript object to a Java string, however this results in an Undefined instance instead of the expected string. Any idea on this could be achieved much appreciated.</p>
  
  <p>in javascript file "test.js"</p>
  
  <pre><code>parser.fct ( {"abc":123,"def":456} )
  </code></pre>
  
  <p>in java</p>
  
  <pre><code>//1.binds javascript calls to Java
  ...
  ScriptEngine engine = new ScriptEngine...
  Bindings bindings = engine.createBindings();
  bindings.put("parser", new Parser());
  engine.eval("test.js");
  
  //2. in Parser class
  public void fct(Object obj){
     Context ctx = Context.enter();
     ScriptableObject scope = ctx.initStandardObjects();
     Object json = NativeJSON.stringify(ctx, scope, obj, null,null);
  
     //json returned is of type Undefined
  
  }
  </code></pre>