如何删除{“结果”:在JSON字符串中?

时间:2016-06-20 11:46:17

标签: json string

我在调用API时有以下JSON结果,如何转换我拥有的JSON字符串,以便我可以看到结果:

var response = request_.responseText;
        var obj = JSON.parse(request_.response);

        var j = obj;
        var js = JSON.stringify(j)
        console.log(js)

JSON输出 var js

{"Result":[{"PK_ID":1,"MedicationId":1,"NHS_Number":"123","Medication_Name":"Asprin","Read_Code":"XaaYI","Dose":"500mg","Date_Started":"02/06/2016","Date_Ended":"03/06/2016"},{"PK_ID":2,"MedicationId":2,"NHS_Number":"1234","Medication_Name":"Ibuprofen","Read_Code":"EtQWEl","Dose":"100mg","Date_Started":"03/02/2016","Date_Ended":"05/02/2016"}]}

如何删除包含在JSON中的{"Result": }代码?

1 个答案:

答案 0 :(得分:2)

更新
 var j = obj;

 var j = obj.Result;



var obj = {
  "Result": [{
    "PK_ID": 1,
    "MedicationId": 1,
    "NHS_Number": "123",
    "Medication_Name": "Asprin",
    "Read_Code": "XaaYI",
    "Dose": "500mg",
    "Date_Started": "02/06/2016",
    "Date_Ended": "03/06/2016"
  }, {
    "PK_ID": 2,
    "MedicationId": 2,
    "NHS_Number": "1234",
    "Medication_Name": "Ibuprofen",
    "Read_Code": "EtQWEl",
    "Dose": "100mg",
    "Date_Started": "03/02/2016",
    "Date_Ended": "05/02/2016"
  }]
};

var j = obj.Result;
var js = JSON.stringify(j);

console.log(js);