[英]Can I save json data in a .js page instead of a .json file
We are building a static app of sorts where a user can publish static pages from our site, download them and install them on their own web server. 我们正在构建一个静态应用程序,用户可以在其中从我们的网站发布静态页面,下载静态页面并将其安装在自己的Web服务器上。 In order to do this we are relying on JSON data which will be stored in json files. 为此,我们依靠将存储在json文件中的JSON数据。 My concern is that we have no way of controlling their servers and I am unclear if their servers will support .json file mime/types. 我担心的是,我们无法控制他们的服务器,我不清楚他们的服务器是否支持.json文件mime / types。
Can we just save the json data in a .js file, instead to avoid this potential problem? 我们可以仅将json数据保存在.js文件中,而不是避免这种潜在问题吗?
Sure. 当然。 Just save it as a variable in JS. 只需将其另存为JS中的变量即可。
var myJsonData = {
"thing": true,
"otherThing:" 4
"fancyArray":[
"hello",
"hi",
"greetings"
]
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.