How to fetch data from object of array

Viewed 32
Response = {
  "assets": [
    {
      "fileName": "rn_image_picker_lib_temp_d8a7529b-42a0-4a3f-9b62-0ae1d48892a2.jpg",
      "fileSize": 67445,
      "height": 400,
      "type": "image/jpeg",
      "uri": "file:///data/user/0/com.dailycast/cache/rn_image_picker_lib_temp_d8a7529b-42a0-4a3f-9b62-0ae1d48892a2.jpg",
      "width": 300
    }
  ]
}

how to fetch URI data from this object?

1 Answers

You should be able to read that URI field with the following one-liner:

var uri = Response['assets'][0]['uri']

What I'm doing here is indexing the assets field of the Response, then indexing the first element of the assets array, then indexing the uri of the first assert element.

Related