what is serialization all about?

前端 未结 5 1973
梦如初夏
梦如初夏 2020-12-30 14:01

Where exactly does serialization comes into the picture? I read about serializtion on the \'net and I have come to know that

it is an interface that

5条回答
  •  没有蜡笔的小新
    2020-12-30 14:20

    In non-object-oriented languages, one would typically have data stored in memory in a pattern of bytes that would 'make sense' without reference to anything else. For example, a bunch of shapes in a graphics editor might simply have all their points stored consecutively. In such a program, simply storing the contents of all one's arrays to disk might yield a file which, when read back into those arrays would yield the original data.

    In object-oriented languages, many objects are stored as references to other objects. Merely storing the contents of in-memory data structures will not be useful, because a reference to object #24601 won't say anything about what that object represents. While an object-oriented system may be able to do a pretty good job figuring out what the in-memory data "mean" and try to convert it automatically to a sensible format, it can't recognize all the distinctions between object references which point to the same object, and those that point to objects which happen to match. It's thus often necessary to help out the system when converting objects to a raw stream of bits.

提交回复
热议问题