title: Convert variable that contain string data into JSON Object for JavaScript REST API
body: <p>Here I have variable named item and contain following data:</p>
  
  <pre class="lang-js prettyprint-override"><code>{
    __metadata: {
      "type": "SP.Data.ClinicalTestingPhaseIIListItem"
    },
    Control: 1,
    Randomization: 2,
    Blindings: 3,
    Groups: 4,
    DoseTitration: 5,
    Stratification: 6,
    PatientsDoseLevel: 7,
    TumourResponse: 8,
    DetermineWarrants: 9,
    Title: 1
  }
  </code></pre>
  
  <p>Now when I pass it to my ajax call written below that gives me a error after some research I get conclusion that the data passed in string format instead of object. </p>
  
  <blockquote>
    <p><strong><code>Microsoft.SharePoint.Client.InvalidClientQueryException</code>:</strong> A node of type <code>PrimitiveValue</code> was read from the JSON reader when trying to read the start of an entry. A <code>StartObject</code> node was expected.</p>
  </blockquote>
  
  <p>Below is my ajax call </p>
  
  <pre><code>jQuery.ajax({
          url: requestUri,
          type: "POST",
          data: JSON.stringify(item),
          headers: header,
          success:function(){
          alert("List itme Inserted Sucessfully");    
          },
          error: function(data){
          console.log(data);
                  alert(data.responseText);
          alert("Error Occured");
          }
  });
  </code></pre>