Kyler Phillips Kyler Phillips - 2 years ago 84
JSON Question

Remove {"Result": in JSON string

I have the following JSON result when calling an API, how can I convert the JSON string I have so I can just see the results:

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

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

JSON Output of
var js


How can I remove the
{"Result": }
code that is wrapped around my JSON?

Answer Source

Update from

 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);


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download