Added error checking on json data.