请教一下cocos creator 怎么将数据写入json文件

如题,自己做了一个关卡编辑器,需要将关卡数据导出成json文件

我也是这样想的,有解决吗

我之前弄过,是通过运行然后将json文件下载下来

saveForBrowser(textToWrite, fileNameToSaveAs) {
if (cc.sys.isBrowser) {
console.log(“浏览器”);
let textFileAsBlob = new Blob([textToWrite], { type: ‘application/json’ });
let downloadLink = document.createElement(“a”);
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = “Download File”;
if (window.webkitURL != null) {
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
else {
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = “none”;
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
}

亲测可以生成Json文件