javascript - 如何将 JSON 文件转换为数组列表
问题描述
我想将我的 JSON 文件转换为一个数组列表,然后我可以访问并使用它来显示网页上的信息。
我的 html 文件
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
console.log(JSON.parse(this.responseText))
}
};
xmlhttp.open("GET", "PATIENT51.txt", true);
xmlhttp.send();
我的 JSON 文件
{
“resourceType”:”RiskAssessment”,
“Notes”: [
{“date”: “05/13/2019”, “note”: “my notes”},
{“date”: “02/22/2018”, “note”: “cool”}
]
}
如何访问05/13/2019
,我尝试使用
myObj.Notes[0].note;
但结果是“未定义”,我希望能够使用日期制作表格——每个日期都会有一个与之关联的注释。
解决方案
推荐阅读
- java - 为什么在使用 listIterator.add() 时会出现 noSuchElementException?
- game-development - 如何在游戏制作者 2 中从枪管中发射子弹 [已解决]
- python - 如何在特殊解析函数内的 ply-yacc 中引发错误?
- c++ - 使用arduino从SD卡存储文件的最后一个值
- c - Rust bindgen 找不到特定于平台的库?
- firebase - 是否可以将本地 Functions 模拟器连接到非本地 Firebase 实时数据库?
- javascript - ParcelJS 模块加载 vs Webpack
- javascript - 加载前不显示 mustache 语法
- android - Batch Drawable Importer 插件在 android 4.0.1 中不起作用
- reactjs - 如何正确键入定义 event.target.value?