Jump to content
Sign in to follow this  
Kevin Castro

how to read the JSON array and print in web page html?

Recommended Posts

consider this is my json array

[
{"products":[{"productname":"Online Test","product":[{"subjectname":"Quants","lessonid":"16","subjectid":null,"subject_covered":"Algebra for SSC","lesson":"15","videoflag":false,"videos":null,"quiz":[{"practice":[{"title":"15.0 - Test of Quantitative Aptitude: Algebra for SSC : Lesson 15.0 ","nid":"21712","quizid":null}],"combo":null,"mock":null}],"ebook":null},{"subjectname":"Quants","lessonid":"17","subjectid":null,"subject_covered":"Trigonometry for SSC","lesson":"16","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"16.0- Test of Quantitative Aptitude: Trigonometry for SSC : Lesson 16.0 ","nid":"21816","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"Quants","lessonid":"18","subjectid":null,"subject_covered":"Mensuration for SSC","lesson":"17","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"17.0- Test of Quantitative Aptitude: Mensuration for SSC : Lesson 17.0 ","nid":"21675","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"Quants","lessonid":"19","subjectid":null,"subject_covered":"Geometry for SSC","lesson":"18","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"18.0 -Test of Quantitative Aptitude: Geometry for SSC : Lesson 18.0 ","nid":"21740","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"GK","lessonid":"02","subjectid":null,"subject_covered":"Test of SSC GK Question","lesson":"2","videoflag":false,"videos":[]

 

 

and i want to print the product array and print the subject name as well as quiz array title in a web page...

 

how to parse the json and display these results in html page?

 

please help me

 

thanks in advance

Share this post


Link to post
Share on other sites

what have you tried? is this data coming back through Ajax? Is it already JSON when you get it?

Share this post


Link to post
Share on other sites

Object properties are accessed using the dot notation obj.property

Array elements are accessed using square brackets and the index of the array arr[2]

 

An array of objects would be accessed like this: arr[2].property

An object with arrays as properties would be accessed like this: obj.property[2]

 

Using this knowledge you can access anything in any data structure.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...