title: Rhino Evaluating a javascript object in Java
body: <p>Im quite new to Rhino and trying to convert a javascript object to a java object but unable to do so. It doesnt seem to evaluate properly.</p>
  
  <p>The javascript that I have is,</p>
  
  <pre><code>var myObject = new Object();
  myObject.string1 = 'Hello';
  myObject.string2 = 'World';
  myObject.id = 1;
  var parser = new Packages.com.MyParser();
  var returnStr = parser.PrintObj(myObject);
  </code></pre>
  
  <p>And I have the following java class that I want to evaluate this to,</p>
  
  <pre><code>public class Person extends ScriptableObject {
  
      private int id;
      private String string1;
      private String string2;
  
      public Person() {}
  
      public void jsConstructor() {
          this.string1 = "";
          this.string2 = "";
          this.id = 0;
      }
  
      public int getID()
      {
          return this.id;
      }
  
      public void jsSet_id(int value)
      {
          this.id = value;
      }
  
      public int jsGet_id()
      {
          return this.id;
      }
  
      public String jsGet_string1()
      {
          return this.string1;
      }
  
      public void jsSet_string1(String value)
      {
          this.string1 = value;
      }
  
      public String jsGet_string2() {
          return this.string2;
      }
  
      public void jsSet_string2(String value)
      {
          this.string2 = value;
      }
  
      @Override
      public String toString() {
          return id + " " + string1 + " " + string2;
      }
  
      @Override
      public String getClassName() {
          return "Person";
      }
  </code></pre>
  
  <p>And the skeleton of my parser is,</p>
  
  <pre><code>public class MyParser {
      public String PrintObj(ScriptableObject obj) {
          // Need to convert to Person object here
          // Obviously casting doesnt work here
          return null;
      }
  }
  </code></pre>
  
  <p>Thanks</p>