error on json parsing on ajax callback

error on json parsing on ajax callback

I am making an ajax call which return the following json

  1.     {"0":"37","id":"37","1":"1","hand_tool_categoy":"1","2":"10 Pcs Allen Key Set","name":"10 Pcs Allen Key Set","3":"handtools182.jpg","image":"handtools182.jpg","4":"ht","type":"ht","5":"{\"f_1\":{\"val\":\"RST- 6A101C\",\"name\":\"art_no\"},\"f_2\":{\"val\":\"\",\"name\":\"feature\"},\"f_3\":{\"val\":\"1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 8 & 10 mm\r\n1\/16, 5\/64, 3\/34, 1\/18, 5\/32, 3\/16, 7\/32, 1\/4, 5\/16, 3\/8 inches\",\"name\":\"size\"},\"f_4\":{\"val\":\"100 set\/ctn\",\"name\":\"packing\"},\"f_5\":{\"val\":\"\",\"name\":\"highlights\"},\"f_6\":{\"val\":\"\",\"name\":\"contents\"},\"f_7\":{\"val\":\"\",\"name\":\"price\"}}","details":"{\"f_1\":{\"val\":\"RST- 6A101C\",\"name\":\"art_no\"},\"f_2\":{\"val\":\"\",\"name\":\"feature\"},\"f_3\":{\"val\":\"1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 8 & 10 mm\r\n1\/16, 5\/64, 3\/34, 1\/18, 5\/32, 3\/16, 7\/32, 1\/4, 5\/16, 3\/8 inches\",\"name\":\"size\"},\"f_4\":{\"val\":\"100 set\/ctn\",\"name\":\"packing\"},\"f_5\":{\"val\":\"\",\"name\":\"highlights\"},\"f_6\":{\"val\":\"\",\"name\":\"contents\"},\"f_7\":{\"val\":\"\",\"name\":\"price\"}}"}

The jquery ajax call is as

  1.     $.ajax({
  2.      type : "POST",
  3.      cache : false,
  4.      url : "admin_managehtitem.php?action=getdetails&id="+id,
  5.      data  : '',
  6.      success : function(data) {
  7.      console.log(data);
  8.      var obj = JSON.parse(data);
  9.      console.log(obj);
  10.      var obj2 = JSON.parse(obj.details);
  11.      console.log(obj2);
  12.      },
  13.      error: function() {
  14.      alert("Some internal error occurred. Please try again!");
  15.      }
  16.     });


  1. I am doing JSON.parse on the data 

  1.     var obj = JSON.parse(data);
  2.     var obj2 = JSON.parse(obj.details);

But I am getting this error on the second JSON.parse for obj.details

Uncaught SyntaxError: Unexpected token
 
That is coming up perhaps because of the slash characters. 

The json is formed on php side using 

  1. json_encode($db->Record);

Moreover when i add the following on server side

  1. header("content-type:application/json");
the callback enters the error part!

How can i handle such situation. Thanks