Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 Javescript 读取本地机器中的 JSON 文件,并将其解析为 Javascript 对象,例如以下代码:
var parsed = JSON.parse(JSON_file);
是否可以从磁盘读取文件?或者还有其他方法可以做到这一点。谢谢。
这是一个很好的教程,介绍如何使用 HTML5 的 FileReader API 进行操作,但有一个限制:您只能通过文件输入字段与用户选择的文件进行交互。
http://www.html5rocks.com/en/tutorials/file/dndfiles/