2
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?

5
  • 1
    I would guess that, as you're using data.d, the JSON is already parsed. jQuery will, in most scenarios, detect JSON and parse it for you. I'd see if typeof data === "object", and if it is, you should be able to iterate over data (as an array).
    – Matt
    Commented Jul 12, 2012 at 10:12
  • 1
    ITs not a JSON, here JSON is inside an array.
    – kiranvj
    Commented Jul 12, 2012 at 10:14
  • okies then how to parse this.. will you please explain me. Commented Jul 12, 2012 at 10:16
  • 1
    @kiranvj that is still valid JSON.
    – Rob Agar
    Commented Jul 12, 2012 at 10:16
  • For reference, there is no such thing as a "JSON object" (with the arguable exception of the actual JSON module, 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.
    – cHao
    Commented Jul 13, 2012 at 5:35

1 Answer 1

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);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.