如何访问大型JSON对象中的指定属性?

时间:2019-01-04 15:54:42

标签: javascript reactjs

我正在尽力访问此大型JSON对象的特定属性。当我使用JSON.stringify输出对象时,该属性似乎在那里,但是当我尝试通过代码访问该属性时,它说未定义。我不太明白为什么...?也许我的知识库中有一个漏洞。你能帮我解决这个问题吗?非常感谢。

当我输出this.props.currentBuilding.apartments [0]时,我得到了这个JSON对象

{
  "Id": 1341394,
  "PlutoId": 13684,
  "Borough": 1,
  "Block": "00837",
  "Lot": "0036",
  "Bin": 1015897,
  "HouseNo": "3",
  "HighHouseNo": "7",
  "StreetName": "WEST 35TH STREET",
  "ZipCode": 10001,
  "Buildings": 1,
  "Area": "7,406 SF",
  "Building": "Office: Designed Exclusively Banking",
  "LastTrade": "2001-11-19T05:00:00.000Z",
  "SalePrice": "0",
  "LastMortgage": "06/23/2015",
  "TotalDebt": 13660000,
  "Neighborhood": "Midtown South ",
  "YearBuilt": 1912,
  "BldgArea": 87301,
  "Address": "3 WEST 35TH STREET",
  "OriginalMortgage": 0,
  "NeighborhoodFull": "Midtown-Midtown South",
  "lender": "MANUFACTURERS TRADERS TRUST COMPANY",
  "LLCName": "ISTA WEST 35TH STREET LLC",
  "ParentCompanyName": null,
  "ParentCompanyAddress": null,
  "imageLink": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRNPgpLZpTno_zpXU7NpquNu7Z1Y2QvHFiwQl7h4EY7c5mahU7HePpp_Jk",
  "image_url": ""
}

我想访问此对象中的address属性,但是很遗憾,我无法做到这一点。

我希望只在该对象中输出address属性。

1 个答案:

答案 0 :(得分:1)

JSON中的属性名称区分大小写。地址属性为地址(大写字母“ A”)。

this.props.currentBuilding.apartments[0].Address
                                         ^