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 + ")");
上图中有一个变量,我们以 json 格式输入数据。但我需要的是,我有 api 的 url,我必须从那里获取 json 并将其分配给变量。怎么做?