JSON.stringify on Java object
Viktor Gamov
viktor.gamov at gmail.com
Mon Sep 16 18:14:20 PDT 2013
Hello Nashorn team,
I have a question regarding conversion java object to json using JSON.stringify. Is it possible?
Here is my test method
@Test
public void convertToJson() throws ScriptException, NoSuchMethodException {
Person person = new Person();
person.setFirstName("Vik");
person.setLastName("Gamov");
person.setSsn("111-11-11");
Invocable invocable = (Invocable) engine;
Object x = invocable.invokeMethod(engine.eval("JSON"), "stringify", person);
System.out.println(x);
}
Prints null. Please advise.
Thanks
--
With Best Regards,
Vik Gamov
More information about the nashorn-dev
mailing list