问题描述
据我了解,反序列化将字节流变成一个对象.
As far as I understand, deserialization is turning a stream of bytes into an object.
解析有点一样,通常将字符串转换为某种数据结构.
Parsing is kinda the same, usually turning a string into some data structure.
正在解析一种反序列化吗?您可以认为它们是同义词吗?
Is parsing a type of deserialization? Can you consider them synonymous?
推荐答案
解析是更笼统的术语.
反序列化通常用于面向对象的语言.反序列化的结果是一个对象,而解析的结果可以是任何类型的数据.
Deserialization is commonly used in the context of object oriented languages. The result of deserialization is an object while the result of parsing can be any type of data.
即使在对象创建的上下文中,解析也更加通用.例如,如果您创建一个对象,并且仅从文件中解析出构造函数所需的部分数据,而其余数据作为用户输入提供,那么我就不会将其称为反序列化.
Even in the context of object creation, parsing is more general. If for example you create an object and only part of the data required by the constructor is parsed from a file while the rest of the data is provided as user input, I wouldn't call it deserialization.
这篇关于反序列化与解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!