我有AS-JSON字符串解析错误
var RetailerData = {};
// The object that the JSON string should represent, can use this as it is if you want.
RetailerData.webSites = [
{
id: 1,
text: 'J.Crew',
image: 'images/retailer-logo/jcrew.png',
extra: 'www.jcrew.com'
},
{
id: 2,
text: 'GAP',
image: 'images/retailer-logo/gap.png',
extra: 'www.gap.com'
}];
我想使用jQuery $.parseJSON
让每个值解析它一个JSON字符串。我曾尝试过使用
var obj = $.parseJSON(RetailerData.webSites);
$.each(obj, function() {
console.log(this['id']);
});
但是在每次尝试中都会出现连续错误。任何人都可以告诉一个合适的方法来做这件事 在此先感谢。
JSON是一个**字符串**。你在那里已经有了一个JavaScript对象。这里没有太多解析,呃? –
对不起,如果我问了一些愚蠢的东西,我还处于学习阶段。你能以简单的方式解释我吗?谢谢 – user1719367