如何在JSON文件或XML文件中保存数据? [英] How I can save data in JSON file or XML file?

查看:197
本文介绍了如何在JSON文件或XML文件中保存数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存有关网球比赛的数据。我想在重新打开应用程序时访问数据。

I want to save data about a tennis match. I want to access data when I reopen application.

推荐答案

这取决于您的架构。

对于单页应用程序,它只是运行在浏览器中,一种常见的方法是使用HTML5的 localStorage 这是一种以不错的方式存储数据的好方法,因为它不是安全持久的。我清除你的浏览器临时文件,数据将丢失。请参阅 http://html5demos.com/storage [ ^ ]

对于更高级的持久化数据方式,您需要一个客户端 - 服务器架构,也许您也想拥有一个数据库。在这种情况下,数据被加载并传递回服务器,在那里存储数据(最好是在数据库中)。搜索SOA / SOAP,REST / Restful,JSON Web服务,CRUD操作,WCF,Web API。请参阅两个可能的示例使用AngularJS,WebAPI和实体的基本SPA应用程序框架 [ ^ ]和初学者指南使用Backbone.js和Marionette.js创建单页应用程序 [ ^ ]



玩得开心



哦,当然还有最新的实时技术,我忘了提及,比如websockets(SignalR,SockJS,Socket.io)。
This depends on your architecture.
For a Single Page Application, that simply runs in the Browser, a common way is to use HTML5's localStorage This is a good way to store data in a "nice to have" manner, because it is not persisted safely. I you clear your browser temp-files, data will be lost. see http://html5demos.com/storage[^]
For a more advanced way of persisting data you will need a client-server-architecture and maybe you want to have a database, too. In this scenario data is loaded and passed back to the server, where it is stored (preferably in a database). search for for SOA/SOAP, REST/Restful, JSON Webservices, CRUD Operations, WCF, Web API. see two possible examples A basic SPA application using AngularJS,WebAPI and Entity Framework[^] and A Beginner's Guide for Creating Single Page Applications using Backbone.js and Marionette.js[^]

have fun

oh, and of course the latest "real time" techniques, I forgot to mention, like websockets (SignalR, SockJS, Socket.io).


这篇关于如何在JSON文件或XML文件中保存数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆