var Response = $.parseJSON(data.d);
this code is not working..
my json object is
[{"ItemId":1,"ItemName":"Sizzler"},{"ItemId":2,"ItemName":"Starter"},{"ItemId":3,"ItemName":"Salad"}]
How can i parse this?
asked Jul 12, 2012 at 10:11
Rikin Thakkar
1,2784 gold badges13 silver badges27 bronze badges
1 Answer 1
got the solution. I have included 2 jquery and because of their clash my code was not working.. my working code is : var jsonp = data.d;
var lang = '';
var obj = $.parseJSON(jsonp);
$.each(obj, function() {
lang += this['ItemId'] + " ";
});
alert(lang);
answered Jul 13, 2012 at 5:32
Rikin Thakkar
1,2784 gold badges13 silver badges27 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
data.d, the JSON is already parsed. jQuery will, in most scenarios, detect JSON and parse it for you. I'd see iftypeof data === "object", and if it is, you should be able to iterate overdata(as an array).JSONmodule, but that's nitpicking). JSON is a format for strings that represent objects. If you have an object that's not a string, it's by definition not JSON; it's just an object.