是否有使用 XML 进行无开销对象序列化的模式?

发布于 2024-07-10 16:47:00 字数 221 浏览 4 评论 0原文

就像在 javascript 中使用 JSON 一样吗? 至少静态属性?

或者甚至可以用于哈希表流?

希望找到类似

Object.Serialize(stream) 的东西(其中流是一个文件,可以使用某种默认格式(例如 XML)覆盖您选择的其他可能的候选目标)是否过于简单化?

使用对象 obj = stream.Deserialize() ...

In the same way that you can use JSON in javascript? At least the static properties?

Or maybe even for hash-table streaming?

Is it oversimplistic about hoping to find something like

Object.Serialize(stream) where stream is a file, overrideable with your choice of other likely candidate targets, using some default format, say XML?

With Object obj = stream.Deserialize() ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韬韬不绝 2024-07-17 16:47:00

Java 从 1.4 开始通过 XMLEncoder 支持此功能。 该格式非常紧凑,并且 XMLEncoder 允许覆盖特定对象类的序列化,因此您可以在合适的地方使用默认值,并在其他地方做任何您想做的事情。

Java supports this with the XMLEncoder since 1.4. The format is quite compact and XMLEncoder allows to override the serialization of specific object classes, so you can use the default where it fits and do whatever you want to elsewhere.

↘人皮目录ツ 2024-07-17 16:47:00

我建议您查看XStream for .Net。 我没有使用过该变体,但发现原始的 XStream 在 Java 中使用起来非常简单。

I suggest you look at XStream for .Net. I haven't used that variant, but found the original XStream quite straightforward to use in Java.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文