top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to parse JSON in JQuery?

0 votes
387 views
How to parse JSON in JQuery?
posted Jul 9, 2017 by Ram Jana

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

JQuery provides a metohd called "parseJSON()" which takes a well-formed JSON string and returns the resulting JQuery object.

Syntax

$.parseJSON(text)

Parameters

text
the JSON string.
(return value)
the resulting JQuery object. Undefined if not valid.

Example

var json = '[{"id":"1","tagName":"apple"},{"id":"2","tagName":"orange"},
{"id":"3","tagName":"banana"},{"id":"4","tagName":"watermelon"},
{"id":"5","tagName":"pineapple"}]';

$.each($.parseJSON(json), function(idx, obj) {
    alert(obj.tagName);
});
answer Jul 10, 2017 by Shyam Chakraborty
...