Javascript “什么是”呢;。项目“;及";。json();

Javascript “什么是”呢;。项目“;及";。json();,javascript,angular,Javascript,Angular,我正在读一本关于Angular 2的书,有一段代码: return this.http.get(queryUrl) .map((response: Response) => { return (<any>response.json()).items.map(item => { // console.log("raw item", item); // uncomment if you want to debug return new Se

我正在读一本关于Angular 2的书,有一段代码:

return this.http.get(queryUrl)
  .map((response: Response) => {
    return (<any>response.json()).items.map(item => {
      // console.log("raw item", item); // uncomment if you want to debug
      return new SearchResult({
        id: item.id.videoId,
        title: item.snippet.title,
        description: item.snippet.description,
        thumbnailUrl: item.snippet.thumbnails.high.url
      }); 
    });
  });
返回这个.http.get(queryUrl)
.map((响应:响应)=>{
return(response.json()).items.map(item=>{
//log(“原始项”,项);//如果要调试,请取消注释
返回新的搜索结果({
id:item.id.videoId,
标题:item.snippet.title,
描述:item.snippet.description,
缩略图url:item.snippet.thumbnails.high.url
}); 
});
});

第3行中的
.json()
是什么?我在谷歌上搜索过,但是找不到关于这个方法的任何描述。

无论何时调用任何请求,您使用的
Http
对象都会返回一个
可观察的
对象,在本例中是
get

方法名为
.json()
,它试图将
响应
对象的主体作为已解析的
json
对象返回,以便更容易使用它

items
只是假设响应主体有一个items属性,因此他正在执行的
get
希望返回如下内容:

{items:…}

看看:


并且

无论何时调用任何请求,您正在使用的
Http
对象都会返回一个
可观察的
对象,在本例中为
get

方法名为
.json()
,它试图将
响应
对象的主体作为已解析的
json
对象返回,以便更容易使用它

items
只是假设响应主体有一个items属性,因此他正在执行的
get
希望返回如下内容:

{items:…}

看看:


而且

np,很高兴它有帮助!np,很高兴它有帮助!