javascript - 通过键检索 json 数据
问题描述
const username = 'merMan';
fetch("./datz.json")
.then(response => response.text())
.then((response) => {
console.log(response);
})
我的数据response
如下所示,仍然很难简单地获取用户特定的数据。我的response
数据输出如下。我试过使用find
,但总是返回 find is not a function,response[username]
也不起作用。
[{"mermAn":{"baseMapId":"459cc334740944d38580455a0a777a24","customBaseMap":"","zoomn":"5","orient":"0","centLon":"-93.69999999999843","centLat":"38.64999999999935"},
{"catWoman":{"baseMapId":"459cc334740944d38580455a0a777a24","customBaseMap":"","zoomn":"5","orient":"0","centLon":"-93.69999999999843","centLat":"38.64999999999935"},
{"Riddler":{"baseMapId":"459cc334740944d38580455a0a777a24","customBaseMap":"","zoomn":"5","orient":"0","centLon":"-93.69999999999843","centLat":"38.64999999999935"}}]
解决方案
推荐阅读
- csv - Bash:将空列添加到具有未知位置的 CSV
- linux - 无法使用 influxdb docker 映像中的“Influx”命令访问或创建数据库
- javascript - 以 onsubmit 形式调用 ajax 函数
- java - 我是否需要服务器端的“jersey-client”依赖项来支持用它实现的客户端?
- python - 如何绕过 AKAMAI 机器人检测以使用 requests_html、Beautiful Soup 进行数据抓取
- node.js - 如何填充在mongodb中聚合查找后返回的子文档?
- excel - 从另一个工作表的单元格列替换第一行中的标题名称
- python - Pygraphviz-警告:不支持重叠值“棱镜” - 忽略 warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)
- twig - 循环头部内的变量/索引
- javascript - 如何将数组的 For 循环更改为 forEach?