[英]How to fetch nested json array in react native
我需要獲取這個 Json 但我不能...請幫幫我!!
傑森
[
"got_new_event",
{
"type": "exchange",
"data": [
{
"m": 0.1556,
"c": "USGLDKG",
"l": 39264,
"a": 39264,
"t": "085542",
"b": 39257
}
]
}
]
反應原生
console.log(event.data) // event.data => 下面的 json
我需要在數據中獲取 c。
嘗試 res[1].data[0].c 代替。 主要的 res 和 data 是一個數組(或 JSON 數組),因此您必須使用索引來訪問它
res = [ "got_new_event", { "type": "exchange", "data": [ { "m": 0.1556, "c": "USGLDKG", "l": 39264, "a": 39264, "t": "085542", "b": 39257 } ] } ] console.log(res[1].data[0].c)
嘗試res[1].data[0].c
代替。 主要的res
和data
是一個數組(或 JSON 數組),因此您必須使用索引來訪問它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.