【发布时间】:2020-03-05 22:17:57
【问题描述】:
我正在使用 node.js。 我已经设法使用异步加载和解析我的 .json 文件。 整个概念对我来说非常新,我可以在控制台中看到我的 .json 数据,但我不确定现在如何实际使用我的数据,..
async function getJsonFile() {
let response = await fetch('example.json');
let responsejson = await response.json();
let str = JSON.stringify(responsejson);
let jsonData = JSON.parse(str);
return jsonData;
};
getJsonFile().then(console.log); // I see my .json file in console, how can I use it ?
}
【问题讨论】:
标签: node.js json parsing asynchronous