This is my response
["{\"id\":1,\"name\":\"JOHN\"}","{\"id\":2,\"name\":\"MICHEAL\"}"]
var json = JSON.parse(demp);
console.log(json[0].id); says undefined.
How to get id and name ?
Thank you
My suggestion is to use a loop to iterate in array as you have suggested in the question.
To me your response is an array so you should JSON.parse() the array instead just var demp:
var DEMP = ["{\"id\":1,\"name\":\"JOHN\"}", "{\"id\":2,\"name\":\"MICHEAL\"}"];
for (var i = 0, syze = DEMP.length; i < syze; i++) {
var json = JSON.parse(DEMP[i]);
console.log('Response ID is --> '+json.id +
' Response name is --> ' + json.name);
}