title: Is there an easy way to parse JSON in Java without using some extra library?
body: <p>I'm really new to JavaScript and JSON.  I am writing a Java servlet that needs to parse JSON into Java objects, but the trick is that I cannot use external libraries such as json-simple or gson.</p>
  
  <p>So I've already saved the contents of the JavaScript file in a String called "contents"...</p>
  
  <pre><code>contents = "myVar = " + contents + ";";
  
  BufferedWriter bWriter = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
  ScriptEngineManager manager = new ScriptEngineManager();
  ScriptEngine engine = manager.getEngineByName("JavaScript");
  Object returnVal = engine.eval(contents);            
  NativeObject a = (sun.org.mozilla.javascript.internal.NativeObject) engine.get("myVar");
  
  Object[] ids = a.getAllIds();
  
  for (Object id : ids) {
      String newId = (String) id;
      bWriter.write("\n" + newId);
  }
  </code></pre>
  
  <p>This will print out all of the names of the various attributes of my object correctly. Thing is, I have no idea what to do from here.  I've tried all sorts of different methods of NativeObject to no avail.</p>
  
  <p>There must be something really obvious I'm missing.  Can anyone help me out?</p>
  
  <p>Thanks.</p>