I apologize if this might be similar to my previous question. Why does searching for a node which doesn’t exist in JSON parse cause every other valid node to fail?
json.track.wiki.summary causes all to error
json.track.name is fine if used without the previous
//JSON data
{
"track": {
"id": "434483410",
"name": "Written in the Stars",
"mbid": "",
"url": "http://www.last.fm/music/Tinie+Tempah+(Feat.+Eric+Turner)/_/Written+in+the+Stars",
"duration": "208000",
"streamable": {
"#text": "0",
"fulltrack": "0"
},
"listeners": "108",
"playcount": "1523",
"artist": {
"name": "Tinie Tempah (Feat. Eric Turner)",
"mbid": "",
"url": "http://www.last.fm/music/Tinie+Tempah+(Feat.+Eric+Turner)"
},
"toptags": "\n "
}
}
Subsequent access will error for valid nodes. Eliminate the request for missing data and subsequent request will work. there must be a way to test an object before you use it so it won’t FUBAR the data.
This data would be OK
//JSON Data
{
"track": {
"id": "517047006",
"name": "Skyscraper",
"mbid": "a92f853d-ad6d-490e-a820-4cff9cc1f224",
"url": "http://www.last.fm/music/Demi+Lovato/_/Skyscraper",
"duration": "222000",
"streamable": {
"#text": "1",
"fulltrack": "0"
},
"listeners": "114757",
"playcount": "1424456",
"artist": {
"name": "Demi Lovato",
"mbid": "faf4cefb-036c-4c88-b93a-5b03dd0a0e6b",
"url": "http://www.last.fm/music/Demi+Lovato"
},
"album": {
"artist": "Demi Lovato",
"title": "Unbroken",
"mbid": "9c195a9b-2db4-4b63-9337-6d8152244742",
"url": "http://www.last.fm/music/Demi+Lovato/Unbroken",
"image": [{
"#text": "http://userserve-ak.last.fm/serve/64s/69672054.png",
"size": "small"
}, {
"#text": "http://userserve-ak.last.fm/serve/126/69672054.png",
"size": "medium"
}, {
"#text": "http://userserve-ak.last.fm/serve/174s/69672054.png",
"size": "large"
}, {
"#text": "http://userserve-ak.last.fm/serve/300x300/69672054.png",
"size": "extralarge"
}],
"@attr": {
"position": "11"
}
},
"toptags": {
"tag": [{
"name": "pop",
"url": "http://www.last.fm/tag/pop"
}, {
"name": "ballad",
"url": "http://www.last.fm/tag/ballad"
}, {
"name": "female vocalists",
"url": "http://www.last.fm/tag/female%20vocalists"
}, {
"name": "inspirational",
"url": "http://www.last.fm/tag/inspirational"
}, {
"name": "demi lovato",
"url": "http://www.last.fm/tag/demi%20lovato"
}]
},
"wiki": {
"published": "Sat, 20 Aug 2011 18:25:23 +0000",
"summary": "The Skyscraper Songfacts says: On November 1, 2010, Demi's publicist announced the Disney star had entered a treatment facility for "
physical and emotional issues,
" which was subsequently reported to include an eating disorder and self-cutting. Her first single since her stint in treatment finds the singer/actress finding strength in the wake of a fading relationship and it symbolizes her resilience in the face of her personal issues.",
"content": "The Skyscraper Songfacts says: On November 1, 2010, Demi's publicist announced the Disney star had entered a treatment facility for "
physical and emotional issues,
" which was subsequently reported to include an eating disorder and self-cutting. Her first single since her stint in treatment finds the singer/actress finding strength in the wake of a fading relationship and it symbolizes her resilience in the face of her personal issues.\n \nUser-contributed text is available under the Creative Commons By-SA License and may also be available under the GNU FDL."
}
}
}
The error is not causing the other code to fail. When the first line errors it stops execution so that the other code is never reached.
You can add something like this: