如何使用javascript解析json对象?

时间:2022-04-12 07:35:38
var Response = $.parseJSON(data.d);

this code is not working..
my json object is

这段代码不起作用。我的json对象是

[{"ItemId":1,"ItemName":"Sizzler"},{"ItemId":2,"ItemName":"Starter"},{"ItemId":3,"ItemName":"Salad"}]

How can i parse this?

我如何解析它?

1 个解决方案

#1


1  

got the solution. I have included 2 jquery and because of their * my code was not working.. my working code is : var jsonp = data.d;

得到了解决方案。我已经包含了2个jquery,由于它们的冲突,我的代码无法工作。我的工作代码是:var jsonp = data.d;

var lang = '';

var obj = $.parseJSON(jsonp);

$.each(obj, function() {

    lang += this['ItemId'] + " ";

});
alert(lang);

#1


1  

got the solution. I have included 2 jquery and because of their * my code was not working.. my working code is : var jsonp = data.d;

得到了解决方案。我已经包含了2个jquery,由于它们的冲突,我的代码无法工作。我的工作代码是:var jsonp = data.d;

var lang = '';

var obj = $.parseJSON(jsonp);

$.each(obj, function() {

    lang += this['ItemId'] + " ";

});
alert(lang);