类的 XML 或 JSON 完整序列化
我需要知道是否可以完全用 XML 或 json 序列化一个类。 我不想只序列化数据,还想序列化所包含的算法。 我知道这听起来很奇怪,但我需要它才能完成一项通用的工作 “无语言”网格计算系统的上传器。谢谢文
森佐
I need to know if is possible to serialize a class entirely in XML or json.
I don't want to serialize only data but also the algorithms included.
I know it could be sound strange but I need it in order to make a generalized job
Uploader for a "language-less" grid computing system. Thank you
Vincenzo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在某些语言(例如 LISP)中,代码和数据本来就没有区别。许多其他语言(尤其是动态语言)提供了一种从字符串执行代码的方法。
因此,您可以将函数表示为在接收方执行的一串程序代码。然而,程序代码没有预定义的序列化,并且提取它首先可能很复杂。
要首先获取代码,您必须使用一些高级反射。例如,在Python中,您 可以使用
inspect.getsourcelines
。In some languages (such as LISP), there is no distinction between code and data in the first place. Many other languages (especially dynamic ones) provide a way to execute code from a string.
Therefore, you can just represent functions as a string of program code that gets executed at the recceiver's side. However, there is no predefined serialization for program code, and extracting it may be complicated in the first place.
To get the code in the first place, you'll have to use some advanced reflection. For example, in Python you can use
inspect.getsourcelines
.