1
1
1ss1za2020-08-05 14:26:20
JavaScript
1ss1za, 2020-08-05 14:26:20

How to get the desired value from json?

I need to get the coordinates of the first group on page load:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 0,
      "geometry": {
        "type": "Point",
        "coordinates": [43.25004107453103,76.85998149999989]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    },
    {
      "type": "Feature",
      "id": 1,
      "geometry": {
        "type": "Point",
        "coordinates": [44.871922574608725,65.49894300000001]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    },
    {
      "type": "Feature",
      "id": 2,
      "geometry": {
        "type": "Point",
        "coordinates": [50.2903700730929,57.20066600000004]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    },
    {
      "type": "Feature",
      "id": 3,
      "geometry": {
        "type": "Point",
        "coordinates": [47.8081355741069,67.64627599999994]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    },
    {
      "type": "Feature",
      "id": 4,
      "geometry": {
        "type": "Point",
        "coordinates": [49.777560573352694,73.11230899999993]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    },
    {
      "type": "Feature",
      "id": 5,
      "geometry": {
        "type": "Point",
        "coordinates": [53.30622807114135,69.39650849999988]
      },
      "properties": {
        "balloonContentBody": "<div class='object-info'>lorem</div>"
      },
      "options": {
        "preset":"mark#icon",
        "hideIconOnBalloonOpen": false
      }
    }
  ]
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2020-08-05
@1ss1za

const obj = {your json}
obj.features[0].geometry.coordinates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question