user3717575
user3717575

Reputation:

Reading a local json file

I'm developing an offline "application", based on HTML5. For my purpose I need to read a local json file but, as I experienced and as I read, through javascript this option is unavailable because of security policies.

Have you any idea about how to bypass the problem? Every hint is well accepted.

Upvotes: 0

Views: 459

Answers (2)

Raxa
Raxa

Reputation: 382

If you want to create an "offline application" than why do you want to use webtools like a browser (and not JavaFX, Windows, ...).

You can say that you want to use the browser as a client for your purposes (or you are webdeveloper). Then you can use a local server to serve you "offline". Simple to start most of them not even to install or needed a large environment.

There are a plenty of local server and they are very powerfull to do anything you want. Search the web for web servers, languages or frameworks like: play framework, nodejs and many many more. After using such a server you can access any local service or local files.

This is how webdevelopers work on their local machines and transfering that to the target server afterwards.

Upvotes: 0

Matt
Matt

Reputation: 3120

That's not entirely true.

Chrome has some security restrictions that prevent local JSON being read by default; however Firefox for example works fine out of the box.

There are some workarounds for Chrome, however the fixes usually rely on modifying settings on the clients machine.

Upvotes: 1

Related Questions