如何像打字稿中的数组一样解析 Json 对象。 MAP Firestore 内的 MAP

how to parse Json object like an array in typescript . MAP inside MAP firestore

我想像数组一样解析 driverDocumentDetails

JSON是从android(Java)HashMap数据结构实现的 Angular MAP 中的 Firestore MAP

{ 
   "driverDocumentDetails":{ 
      "fhgfh":{ 
         "documentCategoryID":"fhgfh",
         "documentCategoryName":"Pan Card",
         "documentUploadedDateTime":null,
         "reasonForRejection":null,
         "uploaded":false,
         "uploadedDocumentURL":null,
         "verified":false
      },
      "bjhbh":{ 
         "documentCategoryID":"bjhbh",
         "documentCategoryName":"Driving License",
         "documentUploadedDateTime":null,
         "reasonForRejection":null,
         "uploaded":false,
         "uploadedDocumentURL":null,
         "verified":false
      },
      "hgvjh":{ 
         "documentCategoryID":"hgvjh",
         "documentCategoryName":"NOC",
         "documentUploadedDateTime":null,
         "reasonForRejection":null,
         "uploaded":false,
         "uploadedDocumentURL":null,
         "verified":false
      }
   },
   "driverID":"bhbjhbjhbj",
   "hgchg":[ 
      { 
         "bjnk":"jhbjhb",
         "fhfyhgf":"jjb"
      },
      { 
         "gfhg":"jgjuy",
         "gh":"guguj"
      }
   ]
}
onCustom(recordRow) {
    console.log("onCustom Driver docs data---->",recordRow);
    this.crudService.ReadDriverDocuments(recordRow.data.id).subscribe(data => {

    this.driverDocument = data.data();
    console.log('ReadDriverDocuments',this.driverDocument);
    });
  }

您可以使用Object.keys获取键,然后将其映射到一个新数组中:

var driverDocumentDetailsArray = Object.keys(this.driverDocument.driverDocumentDetails)
    .map(key => this.driverDocument.driverDocumentDetails[key]);

或者如果可用,只需 Object.values

var driverDocumentDetailsArray = Object.values(this.driverDocument.driverDocumentDetails);