Json 如何在角坐标系中固定不可测对象?
我试图使用webHdfs rest API在angular 7应用程序中获取Hadoop集群中的目录列表 我创建了这个服务Json 如何在角坐标系中固定不可测对象?,json,angular,rest,Json,Angular,Rest,我试图使用webHdfs rest API在angular 7应用程序中获取Hadoop集群中的目录列表 我创建了这个服务 public getHadoopDirList(): Observable<FileStatus[]> { return this.http.get<FileStatus[]>(this.webHdfsUrl, {}).pipe(map(data => data)); } 下面是我用来解析json的类: export class
public getHadoopDirList(): Observable<FileStatus[]> {
return this.http.get<FileStatus[]>(this.webHdfsUrl, {}).pipe(map(data => data));
}
下面是我用来解析json的类:
export class FileStatus {
accessTime: number;
blockSize: number;
childNum: number;
fileId: number;
group: string;
length: number;
modificationTime: number;
owner: string;
pathSuffix: string;
permission: string;
replication: number;
storagePolicy: number;
type: string;
}
下面是json响应的图片
当我尝试迭代结果时,它会显示
错误:尝试区分“[object]”时出错。只允许使用数组和iterables在模板中编写循环,如:
<ul>
<li *ngFor="let hadoopDir of hadoopDirList?.FileStatuses?.FileStatus" >{{hadoopDir.pathSuffix}</li>
</ul>
- {{hadoopDir.pathSuffix}
请显示您正在循环的模板代码- {{hadoopDir.pathSuffix}
- 它不应该是
- {{hadoopDir.pathSuffix}
错误没有显示,但HTMLIt上没有显示类型:try:*ngFor=“let hadoopDir of hadoopDirList.FileStatus”
<ul>
<li *ngFor="let hadoopDir of hadoopDirList?.FileStatuses?.FileStatus" >{{hadoopDir.pathSuffix}</li>
</ul>