使用js / jquery按值访问嵌套的json

时间:2019-06-06 19:04:14

标签: javascript jquery json

我完全陷入困境,感到困惑,并且想了好几个小时。 我得到一个JSON

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
      },
      "properties": {
        "name": "Deventer",
        "measurements": [
          {
            "latestValue": 285.0,
            "unitCode": "cm",
          }
        ],
      },
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
      },
      "properties": {
        "name": "Hansweert",
        "measurements": [
          {
            "latestValue": 104.0,
            "unitCode": "cm",
          }
        ],
      },
    },   
  ]
}

,并且需要访问"latestValue" = "name"的{​​{1}}。

json的内容,长度和因此我所需条目的位置随机不同,并且不可能通过计数"Deventer"进行访问。

所以我需要一种通过(features[*].properties.[1] etc)进行访问的方法

有什么想法吗?

0 个答案:

没有答案