title: Map HTML to JSON
body: <p>I'm attempting map HTML into JSON with structure intact. Are there any libraries out there that do this or will I need to write my own? I suppose if there are no html2json libraries out there I could take an xml2json library as a start. After all, html is only a variant of xml anyway right?</p>
  
  <p><strong>UPDATE:</strong> Okay, I should probably give an example. What I'm trying to do is the following. Parse a string of html:</p>
  
  <pre><code>&lt;div&gt;
    &lt;span&gt;text&lt;/span&gt;Text2
  &lt;/div&gt;
  </code></pre>
  
  <p>into a json object like so:</p>
  
  <pre><code>{
    "type" : "div",
    "content" : [
      {
        "type" : "span",
        "content" : [
          "Text2"
        ]
      },
      "Text2"
    ]
  }
  </code></pre>
  
  <p><strong>NOTE</strong>: In case you didn't notice the tag, I'm looking for a solution in Javascript </p>