title: How to convert Java Pojo to Nashorn Json?
body: <p>I have a Java object that I want to turn into a json object and pass to the Nashorn javascript engine. It is surprisingly difficult to google an answer for this! Can someone tell me how to do it?</p>
  
  <p>I tried this:</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  String inputModelAsString = mapper.writeValueAsString(inputModel);
  </code></pre>
  
  <p>And then passing the string json to the function:</p>
  
  <pre><code>result = invocable.invokeFunction(PROGRAM_FUNCTION, moduleName, inputModelAsString);
  </code></pre>
  
  <p>But it was passed as a string, not as a json.</p>