Question

Problem

I need a way to store and collect JSON data in an entirely offline(!) web application, hosted on a local (shared) machine. Several people will access the app but it will never actually be online.

I'd like the app to:

  • Read and write JSON data continuously and programmatically (i.e. not using a file-upload type schema)
  • Preferably not require any software installation other than the browser, specifically I'd like not to use local server. (edit: I may be willing to learn a bit of Python if that helps)
  • The amount of data I need to store is small so it is very much overkill to use some sort of database.

Solution?

My first thought was to let the html5 file API, just read/parse and write my JSON object to a local txt file, but this appears not to be possible?!

Local storage is not applicable here right, when several people - each with their own browser - need to access the html?

Any ideas?

note

I know this topic is not entirely novel, but I think my situation may be slightly different than in other threads. And I've spent the better part of the last couple hours googling this and I'm none the wiser..

Was it helpful?

Solution

Have you considered Python's Json module? http://docs.python.org/2/library/json.html

Using this you can convert python objects to and from json strings. You can store the strings however you want to

OTHER TIPS

You can't use Localstorage to enable such features because every client will have its own dataset stored.

Have you ever considered using a java applet to handle such informations ?

You could start a java applet using it as a bridge between browser clients and as a store of informations. Browsers could share such information using websockets.

Some times ago I build demo with such solution. Check it at: https://github.com/KingRial/SBrower In this demo I open a browser/tab which starts a java Applet to create a websocket server. All the browsers/tabs are just clients connecting to the websocket server and sharing informations.

Since python is one of the question tags, I am giving a python solution:

import json

#reading
file_json = open("json.txt")
print file_json
python_json_object = json.loads(file_json)
print python_json_object
file_json.close()


#writing
file_json = open("json.txt", 'w')
file_json.write(json.dumps(python_json_object))

My suggestion would be something like WampServer (Windows, Apache, MySQL, PHP). I've seen a few tutorials about adding Python to that mix.

You would have access to reading and writing JSON data to the local storage or placing your data in a local database.

I know you said you don't want to opt for local server, but nodejs could be the solution. If you know JavaScript, then it's very simple to set one server up and let everybody access to the server from any browser. Since it's entirely JavaScript you don't even have conversion issues with the JSON format.

For storing the JSON you can use the FileSystem built-in library of nodejs which lets you read and write from a file, so you don't even need a database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top