简体   繁体   English

反序列化与解析

[英]Deserialization vs. parsing

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? 你能认为他们是同义词吗?

Parsing is the more general term. 解析是更通用的术语。

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. 例如,如果您创建一个对象,并且只从文件中解析构造函数所需的部分数据,而其余数据作为用户输入提供,我不会将其称为反序列化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM