开发者

Generate and load JSON dump in modern browsers?

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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜