【问题标题】:How to obtain specific information from the Json array如何从Json数组中获取具体信息
【发布时间】:2021-10-20 12:24:50
【问题描述】:

我在日志中获取了这个数组,我如何获取地区数据(黄色粗体)。

链接上的图片(无法添加图片)

image link of the array data in the log

【问题讨论】:

标签: html json angular typescript


【解决方案1】:

你能试试这个吗?

items[0].address.district

【讨论】:

    【解决方案2】:

    这可能有效

    items[0]["address"]["district"]
    

    【讨论】:

    • 非常感谢您的帮助,效果很好
    【解决方案3】:

    有很多方法。这取决于你的需要。

    1. 如果你想得到第一项的地区,那么。

      const district = items[0].address.district;

    2. 如果你想从你的列表中获取地区列表,那么

      const districts = items.map(item => item.address.district);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 2014-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多