How do I parse this json with jQuery?
DayEvents: [{
"0": "886",
"event_id": "886",
"1": "5029",
"user_id": "5029",
"2": "Professional",
"user_type": "Professional",
...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The term "parsing" is a bit misplaced since this is already in JSON format. You don’t need to parse it, but just to access it. If it were a large String in JSON format then you indeed need to parse it into an useable JSON object first before accessing.
This JSON contains one property, the
DayEvents, which in turn contains an array[]. You can access properties using dot.operator. You can get an array item at the given index using[index]where zero0denotes the first item.The array in turn contains an object
{}. Or maybe more than one? You can have more than one items in an array, you should then see[{}, {}, {}, ...]and you could then access each item in an loop like so:A single day event object has several properties:
0,event_id,1,user_id,2, etc. You cannot access properties starting with a number using dot.operator, you would then like to use the brace notation:To learn more about JSON, check this tutorial.