A beginners question: I am trying to create and init an Array of users using the following string as initial data in JavaScript:
{ "user": {"notes": [{ "text": "Hello ", "date": "12\/1\/2013 5:01:36 AM", }], "name": "Alex"} }, { "user": { "notes": [{ "text": "Hi ", "date": "12\/1\/2013 5:15:19 PM"}, { "text": "It is me", "date": "12\/1\/2013 6:23:54 PM"}], "name": "Anna"} }
Is it possible in general (how?) or am I completely getting it wrong?
Your JSON is invalid. It contains a syntax error (possible a typo in the question) – an invalid comma after the first user’s
date, and it is also a list of objects that are not enclosed with the array syntax[].The corrected json and example of parsing is:
Demo