Return to Snippet

Revision: 41388
at February 17, 2011 06:36 by eddequincey


Initial Code
<script type="text/javascript">
	var moviereviewtext = '{"title": "Friday the 13th", "year": 1980, "reviews": [{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}, {"reviewer": "Alice", "stars": 4, "text": "The end was good, but a little unsettling"}]}';
	var jsonobj = eval("(" + moviereviewtext + ")");
	var reviewername = jsonobj.reviews[0].reviewer;
	var numberstars = jsonobj.reviews[0].stars;
	var reviewerthoughts = jsonobj.reviews[0].text;
	alert(reviewerthoughts);
</script>

Initial URL
http://www.webmonkey.com/2010/02/get_started_with_json/

Initial Description
Found that the webmonkey tutorial code didn't work as double quotes were used around JSON string.

Initial Title
Variation on webmonkey tutorial:

Initial Tags
javascript, json

Initial Language
JavaScript