1

I am writting a Web app that can save or open a JSON object, what's the best practice to make it behave exactly like an offline desktop app? Should the JSON dump just be in plain text or something?

Could it function properly even if there is no network connection? This means we have to use pure client side Javascript generate a savefile/openfile dialog box.

2 Answers 2

1

You can use localStorage API of modern browsers to save all your needed data.

localStorage gives you ability to store offline data, but make sure that your data fits within quota.

Also keep in mind that native JSON support can be handy in this case (like JSON.stringify()).

Here are some links that might be useful:

JSON in JS

localStorage

Sign up to request clarification or add additional context in comments.

5 Comments

Could I use something other than localStorage? I need the data to be exported and portable.
What you mean by "exported and portable"? All data that is stored in json structures are "portable" in scope of json syntax because it's in serialized form, and you can easily get data from localStorage back.
because, like the JSON dump needed to be carried to a different machine using a usb key ?
If you need to pull out all your data in json you can use JSON.stringify(). All that data is simple (utf8 or unicode which is utf16 i think - not sure about this ) text so you can grab it, paste into your file on usb key, and restore it later.
You can't access file system, because of security reasons (javascript sandbox). Maybe this will be helpful dev.w3.org/2006/webapi/FileAPI
0

I now have the proper technology to do this:

  1. open dialogs: http://www.html5rocks.com/en/tutorials/file/dndfiles/

  2. save JSON data: something like data://application/json;base64,eyJkYXRhIjogImhlbGxvLCBqc29uISJ9

  3. native json parse https://developer.mozilla.org/en-US/docs/Using_native_JSON

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.