我开始与面向对象编程(OOP)和想知道:什么是序列化的意义在面向对象的说法?
当前回答
序列化是指当对象的状态可以保存在文件中时,对象(内存块)转换为一种形式(例如)。
就像做饼干一样,对象是一个面团,饼干是一个序列化的面团。
所以通过“序列化”,你可以把cookie发送给你的朋友。
就像这样:-)
其他回答
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization. ... This illustration shows the overall process of serialization ... Through serialization, a developer can perform actions like sending the object to a remote application by means of a Web Service, passing an object from one domain to another, passing an object through a firewall as an XML string, or maintaining security or user-specific information across applications
从https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/serialization/
(强调我的)
序列化是将对象转换为可存储的位序列。
所以你可以保存这个序列到一个文件,db或通过网络发送。
稍后,您可以将其反序列化为实际对象,并在需要时重用它。
Web服务和AJAX是序列化最常见的例子。对象在向客户端发送响应之前被序列化。
序列化是指当对象的状态可以保存在文件中时,对象(内存块)转换为一种形式(例如)。
就像做饼干一样,对象是一个面团,饼干是一个序列化的面团。
所以通过“序列化”,你可以把cookie发送给你的朋友。
就像这样:-)
序列化只不过是将Java支持的对象转换为文件支持的形式
(OR)
将Java支持的形式转换为网络支持的形式..序列化的主要范围只是将数据从一层传输到另一层…只有序列化的对象,我们可以通过网络发送。
看看这个,它会给你一个很好的解释:
http://en.wikipedia.org/wiki/Serialization
我认为序列化这个术语最常见的用法是将二进制对象转换为XML(或其他字符串)表示形式,这样它就可以存储在数据库/文件中,或者在web服务调用中通过网络发送。反序列化是相反的过程——将XML/字符串转换回对象。
编辑: 您可能遇到的另一个术语是编组/解组。编组基本上是与序列化相同的概念,而解组与反序列化相同。