【发布时间】:2021-04-22 05:16:39
【问题描述】:
我想编写一个 forEach 函数来查找我的 JSON 中的数据 案例:
[[{ {"Plan-Name = "qwe" , "plan_data" = "10"}
{"Plan-Name = "asd" , "plan_data" = "10"}
{"Plan-Name = "wrt" , "plan_data" = "10"}
}]]
我想搜索 wrt 并打印它的 plan_data 我有一个 Current plan = wrt,所以如果当前计划与 Plan_name 匹配,则打印它的 Plan_data 我为我目前的计划 responseJson[0][0]['cuurent_plan'] 而对于 Plan_name responseJson[2]
【问题讨论】:
-
这似乎不是有效的 json - stackoverflow.com/help/minimal-reproducible-example
-
@Shru_v,你的预期输出是什么?
-
我从 API 中获取 JSON,它位于嵌套数组中,所以第一部分我的详细信息有当前计划:HTIL9 在同一个 API 中有特定的 Plan_name 和 Plan_data,大约有 50 个计划,所以我想做的是,如果我当前的计划是 - HTIL9,那么我想从索引 [2] 中找到 HTIL9 的计划详细信息
标签: javascript arrays json react-native