title: Converting serialized form's data to json object
body: <p>I have a cshtml like the following</p>
  
  <pre><code>@using (Html.BeginForm("Save", "Plans", FormMethod.Post, new { @class = "form-horizontal", id = "floorplan-form" }))
  {
              @Html.TextBoxFor(m =&gt; m.FloorPlan.Name, new { placeholder = "Enter text", @class = "form-control" })
  
              @Html.DropDownListFor(m =&gt; m.FloorPlan.GroupId, new SelectList(Model.FloorPlanGroups, "Id", "Name"))             
  }
  </code></pre>
  
  <p>In my javascript(in a separate javascript file), I'm trying to serialize this form and convert it into a JSON object.</p>
  
  <pre><code>var formData = $("#floorplan-form").serialize();
  console.info(formData);
  </code></pre>
  
  <p>prints out </p>
  
  <pre><code>FloorPlan.Name=Test&amp;FloorPlan.GroupId=15 
  </code></pre>
  
  <p>And </p>
  
  <pre><code>var formData = $("#floorplan-form").serializeArray();
  console.info(formData);
  </code></pre>
  
  <p>gives me:</p>
  
  <p><img src="https://i.stack.imgur.com/GDeVO.png" alt="Screen capture"></p>
  
  <p>I have tried doing this </p>
  
  <pre><code>var formData = JSON.parse($("#floorplan-form").serializeArray());
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token o 
  </code></pre>