Reputation: 378
I want to read a JSON file that in my local machinge using Javescript, and parse it to a Javascript object such as this code:
var parsed = JSON.parse(JSON_file);
Is it possible to read the file from the disk? Or there is other methods to do that. Thanks.
Upvotes: 3
Views: 7611
Reputation: 340
Here is a nice tutorial on how you can do it using HTML5's FileReader API, but there is one constraint: you can only interact with a file selected by the user via a file input field.
http://www.html5rocks.com/en/tutorials/file/dndfiles/
Upvotes: 3