[Solved] Loop json string in json object


That’s an invalid “object”. It is supposed to be an array with []. If that’s how your server is giving, you have to change the response there. In case, if you can’t do that, you may parse it right in JavaScript.

var keyword = '{"coconut sugar", "healthy and natural sweetener", "low glycemic index sweetener"}';
keyword = JSON.parse("[" + keyword.substr(1, keyword.length - 2) + "]");
console.log(keyword);

// After this use any array walker to process it.
for (var i = 0; i < keyword.length; i++)
  console.log(keyword[i]);

0

solved Loop json string in json object