保存数据:JSON还是数据库? [英] Save Data: JSON or Database?

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

问题描述

在我制作的html/css/js浏览器游戏中,我确定最终将需要保存功能.我以前使用过数据库保存数据,但我的其他编码朋友建议使用JSON.哪种方法更好?更高效?更容易吗?

In a html/css/js browser game I'm making, I have determined I will eventually need to have saving functions. I've used database save data before, but my other coding friends recommended using JSON. Which method is better? more efficient? easier?

仅保存了几个字符串,大部分是小的整数.使用了一些面向对象的编程.

Only a few strings and mostly small integers are being saved. Some Object-oriented programming is used.

谢谢您的反馈.

推荐答案

您选择的部分取决于您对用户是否有权访问保存数据的关注程度,以及游戏的初衷.

Part of your choice will depend on how much you care about the users having access to the save data and also really what the game is in the first place.

json或xml是很好的保存格式,您可以将所有信息转储到其中并在以后轻松读取.但是,如果将其保存在本地计算机上,则用户显然可以访问它.

json or xml for that matter are nice save formats that you can dump all the info into and easily read it back later. But if you are saving it on the local machine the user obviously has access to it.

这样也可以在本地存储东西,这意味着除非您的游戏已经依赖网络,否则您永远不需要依赖网络,这总是一件好事.

Also storing stuff locally like that means you don't rely on network anything which is always good unless your game already relies on the network.

如果您有任何在线播放方式,则在大多数情况下,本地保存数据显然很糟糕. 反对真的取决于您的游戏在做什么.

If you have any online play local save data is obviously bad in most cases. Against it really depends on what your game is doing.

最后,在运行中使用本地保存的东西要快得多.不用担心担心由于代理或其他阻止用户获取其保存数据的原因而使用户出现网络问题.

Finally it's much faster to get something up in running that uses local saves. And is one less thing to worry about the users having network issues because of proxys or whatever that prevent them from getting their save data.

我想说,使用json/xml进行本地存储更有效/更容易.但是缺点是它的安全性较差,容易被意外删除/损坏(这就是为什么许多Steam游戏都具有本地保存功能以及云备份功能的原因.

I would say local storage with json/xml is more efficient/easier. But the downside is it is less safe and prone to the being accidentally deleted/corrupted (which is why many steam games have local saves but also cloud backup).

这篇关于保存数据:JSON还是数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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