title: JavaScript objects in Java?
body: <p>How do I loop over a string of item and create an object based on that?</p>
  
  <p>I currently have this code:</p>
  
  <pre><code>public static Object ParseParams(String string)
  {
      Object params = new Object();
      String[] lines = string.split("\n");
      for(String line : lines)
      {
          String[] splittedLine = line.split("=");
          params[splittedLine[0]] = splittedLine[1]; //JavaScript syntax, not Java!
      }
      return params;
  }
  </code></pre>
  
  <p>The input string is in this format:</p>
  
  <pre><code>param1=value1
  param2=value2
  foo=bar
  </code></pre>
  
  <p>How do I fix the problematic line?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Sometimes the string would look like this:</p>
  
  <pre><code>foo=bar
  param=1=hello
  param=2=world
  </code></pre>
  
  <p>Would it be possible with Maps in Java to get the output like this:</p>
  
  <pre><code>foo
    bar
  param
    1
      hello
    2
      world
  </code></pre>
  
  <p>So the Maps are sometimes nested, and it you would retrieve <code>hello</code> by calling <code>params.get("param").get("1");</code></p>