Jul 092010
 

I’m writing some REST WebServices that return JSON and wanted to ensure that my JSON was correctly formatted and parsable. Since the JDK ships with a JavaScript engine built into it now, I figured it would be simplest to just use that and avoid any external dependencies. Here’s my code:

Pretty simple overall. The only tricky part is that you need to add the “var obj = ” and the semicolon on the end so that the JavaScript engine can evaluate it correctly.

  One Response to “Parsing JSON via ScriptEngine in the JDK”

  1. This is useful, thanks!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">