当前位置:网站首页>What if some fields don't want to be serialized?
What if some fields don't want to be serialized?
2022-08-02 05:44:00 【The cudgel meat Alexander Lord】
First, let's wire up what is serialization?What is deserialization?
If we need to persist Java objects, such as saving Java objects in files, or transmitting Java objects over the network, serialization is required in these scenarios.
- Serialization
The process of converting a data structure or object into a stream of binary bytes.
- Deserialization
The process of converting the binary byte stream generated during serialization into a data result or object.
In the Java language, what we serialize is the object (Object), that is, the instantiated class (class), but in the half-faced object language such as C++, the struct (structure) defines the dataStructural types, and classes correspond to object types.
So, the main purpose of serialization is to transfer objects over the network or to store objects in the file system, database, or memory.
What if some fields do not want to be serialized?
For variables that do not want to be serialized, use the transient keyword to modify them.
transient
keywords do
Prevent the serialization of variables in the instance that are modified with this keyword; when the object is deserialized, the value of the variable modified by transient will not be persisted and restored.
- A few more notes about transient:
- transient can only modify variables, not classes and methods.
- Transient modified variables, the variable value will be set to the default value of the type after deserialization.For example, if it is a modified int type, the result after deserialization is 0.
- Because the static variable does not belong to any object (Object), it will not be serialized whether it is modified with the transient keyword or not.
边栏推荐
- WordPress是什么?我也想用 WordPress~
- 26. 如何判断一个对象是否存活?(或者GC对象的判定方法)?
- 面试官:大量请求 Redis 不存在的数据,从而打倒数据库,有什么方案?
- 一次跳出最外层循环
- 如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
- 吴恩达机器学习系列课程笔记——第九章:神经网络的学习(Neural Networks: Learning)
- 康威定律对于系统架构很重要吗?
- Andrew Ng's Machine Learning Series Course Notes - Chapter 18: Application Example: Image Text Recognition (Application Example: Photo OCR)
- Nuscenes数据集总结(下)
- Computer Basics
猜你喜欢
Go 语言是如何实现切片扩容的?【slice】
alibaba数据同步组件canal的实践整理
Minecraft 1.18.1、1.18.2模组开发 23.3D动画盔甲制作
Unreal回放系统剖析(上)
Deep blue college - handwritten VIO operations - the first chapter
不会多线程还想进 BAT?精选 19 道多线程面试题,有答案边看边学
最后写入胜利(丢弃并发写入)
【STM32】ADC采集光敏数据(不看库函数手册进行配置)
Research Notes (8) Deep Learning and Its Application in WiFi Human Perception (Part 2)
从事功能测试1年,裸辞1个月,找不到工作的“我”怎么办?
随机推荐
CODESYS指针型变量编程应用(配方)
已更新 联通 电信 tiny模式
[Win11] PowerShell cannot activate Conda virtual environment
C语言:结构体总结
如果有些字段不想进行序列化怎么办?
Nexus 5 phone uses Nexmon tool to get CSI information
STM32 OLED显示屏
C语言特殊运算符
复制延迟案例(4)-一致前缀读
张成分析(spanning test):portfolio_analysis.Spanning_test
(一)代码输出题 —— reverse
MySQL read-write separation mysql-proxy deployment
Qt编写物联网管理平台49-设备模拟工具
Arduino框架下STM32F1/F4系列HID模式程序烧录教程
6个月测试经验,面试跳槽狮子大开口要18K,只会点点点,给我整无语了。。
数据可视化之百变柱状图
无主复制系统(2)-读写quorum
投资组合分析:portfolio_analysis.Tangenvy_portfolio(切点组合)
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
批量--09---批量读文件入表