java - fastjson 与 serialVersionUID 如何建立关系?
伊谢尔伦
伊谢尔伦 2017-04-17 13:56:38
0
3
794

如果使用 fastjson 作为序列化方法,那么即使类实现了 Serializable 接口,其中的 serialVersionUID 似乎也没什么用。

怎么能让 serialVersionUID 起作用,用来防止将内容反序列化的时候类型不符。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
伊谢尔伦

Serializable is used for ObjectInput(Output)Stream. Objects that implement this interface will have one.
Constant for serialVersionUID.
The sequence of fastJson "turns" an object into a json file. If the Serializable interface is implemented, there will be a serialVersionUID attribute.
You can save the serialVersionUID value of the current object during serialization. When deserializing the conversation, check whether it is equal to the last saved value. At this time, you can judge whether they are the same object.
——————Java newbie, please don’t spray lightly

洪涛

No special configuration is required for fastjson serialization and deserialization. The only requirement is that the class you serialize conforms to the Java bean specification.

https://github.com/alibaba/fastjson/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E...

左手右手慢动作

If the object equals method is not overridden, the comparison result is not equal, and the comparison is the memory address.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!