I'm trying to parse the following json line in jquery:
[{
"pk": 19,
"model": "films.movies",
"fields": {
"length": "92",
"name": "Beetle Juice",
"actor": "Keaton",
"img_set": [{
"pk": 42,
"model": "films.img",
"fields": {
"uploaded": "2010-10-08 21:44:30",
"f_movie": 19,
"url_med": "http://www.mondial-infos.fr/wp-content/uploads/2009/10/Beetlejuice.jpg"}
}]
}
},{
"pk": 20,
"model": "films.movies",
"fields": {
"length": "126",
"name": "Batman",
"actor": "Keaton",
"img_set": [{
"pk": 43,
"model": "films.img",
"fields": {
"uploaded": "2010-10-08 21:44:54",
"f_movie": 20,
"url_med": "http://bruehoyt.com/superheroes/DC/batman/bruce/batmankeaton3.jpg"}
}]
}
}]
I can't access anything after img_set though. What am I missing? Is this valid json?
I am attempting the following:
$.getJSON('/films/feeds/movie-by-actor/Keaton/',function(data) {
$.each(data, function(i, movie) {
alert(movie.fields.name);
alert(movie.fields.img_set[0].pk);
});
});
The first alert works. The second does not.
In addition, though I don't know that it matters, this is jquery within a django template.