title: How to create a XMLHttpRequest FormData form object
body: <p>I have a form that has files in it so i am using XMLHttpRequest to handle the sending of the data.</p>
  
  <p>What i am trying to do is to be able to send objects that will be parsed by jackson on the server side. just like you do with json.</p>
  
  <p>For example:</p>
  
  <blockquote>
  <pre><code>{
  "number": 123,
  "string": "Hello World",
  "object": {
      "a": "b"
  }
  </code></pre>
  </blockquote>
  
  <p>}</p>
  
  <p>So i want to create "object". from what i know i can only do "number" and "string" with </p>
  
  <pre><code> formData.append("string", "Hello World");
  </code></pre>
  
  <p>May be there is a way to format it?</p>
  
  <p>when i just append some JSON formated object i get this as a result:</p>
  
  <blockquote>
  <pre><code>    var oData = new FormData(document.forms.namedItem("upload-form"));
       element= {};
       element.id = 2;
       element.type = "dfsdf";
       element.url = "sdfsdff";
       element.version = "asdasd";
       arrayOfelement[0] = framework;
       oData.append("file", this.myfile.getFile());
       oData.append("frameworks",JSON.stringify(arrayOfelement))
       var xhr = new XMLHttpRequest();
       xhr.open('POST', 'design', true);   
       xhr.onload = function(e) { 
          console.log("upload finished");
        };
       console.debug("sending form data", oData);
       xhr.send(oData);
  
  
  
  
  ------WebKitFormBoundaryVWNBucDMZSIlUcXY
  </code></pre>
    
    <p>Content-Disposition: form-data; name="arrayOfElements"
    {"0":{"id":2,"type":"dfsdf","url":"sdfsdff","version":"asdasd"}}</p>
  </blockquote>
  
  <p>which is clearly not going to be parsed into anything on the server side.</p>