0

I have JSONArray Containing JSONObjects

[ { 'title': abc,  'details':xyz,}, {'title': abc2,'details':xyz2}]

How to parse it using jquery?

2
  • In what manner do you want to parse it? What is your desired output? Commented Mar 16, 2011 at 10:48
  • 1
    I'm not sure what your asking, do you have the JSON as a string or is it already and array of objects? Commented Mar 16, 2011 at 10:49

2 Answers 2

1

parseJSON will convert your Json string into a javascript object. The code is something like

var array = $.parseJSON(json);

Then to access the variables you use code like

var title1 = array[0].title;  //title1 is abc
Sign up to request clarification or add additional context in comments.

10 Comments

is this function available with jquery1.4.3-min ?? i m not getting parseJSON in ide
Version added 1.4.1 so it should be available.
My json data contains HTML text.. & a URL too.. does it throw exception when using parseJSON?
Once your string is encoded properly i.e. in double quotes it shouldn't throw an execption
ohk.. i guess the issue is with HTML it contains string like: <img src=""> is there a solution for avoiding exceptions.. it finads end at double quotation of HTML data in JSON
|
0

I think you need to use parseJSON if your array is a string.

http://api.jquery.com/jQuery.parseJSON/

Comments

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.