title: Parse string and remove space and new line and convert to json OBJECT
body: <p>I have a string in the following manner how can i convert this string to JSON object.. My string is</p>
  
  <pre><code>{\"Warranty\": [ \n { \n \"Name\": \"test\", \n \"Type\": \"test2\", \n \"Months\": \"6\", \n }, \n { \n \"Name\": \"Test6\", \n \"Type\": \"test7\", \n \"Months\": \"6\", \n }, \n { \n \"Name\": \"test9\", \n \"Type\": \"test10\", \n \"Miles\": \"10000\", \n } \n ]}
  </code></pre>
  
  <p>Please help to convert the above string to JSON Object.</p>
  
  <p>I tried with the following code but still i am getting string value not an object</p>
  
  <pre><code>  var body = " {\"Warranty\": [ \n { \n \"Name\": \"test\", \n \"Type\": \"test2\", \n \"Months\": \"6\", \n }, \n { \n \"Name\": \"Test6\", \n \"Type\": \"test7\", \n \"Months\": \"6\", \n }, \n { \n \"Name\": \"test9\", \n \"Type\": \"test10\", \n \"Miles\": \"10000\", \n } \n ]} ".replace(/\r?\n|\r/g, "").replace(/\s+/g, "");
      var json=body.replace(/['"]+/g, '');
      var object = JSON.stringify(json);
      object = JSON.parse(object)
  </code></pre>