当前位置:网站首页>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.
transientkeywords 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.
边栏推荐
- 爬虫_爬取wasde月度供需平衡表(实例)
- Nuscenes数据集总结(下)
- 8月1日“海豹数藏”将全网首发民族英雄林则徐《四行行书》数字藏品!
- Platts Analysis-MATLAB Toolbox Function
- Scientific research notes (5) SLAC WiFi Fingerprint+ Step counter fusion positioning
- nr部分计算
- Arduino框架下STM32F1/F4系列HID模式程序烧录教程
- 开放原子开源峰会落幕,百度超级链牵头成立XuperCore开源工作组
- P1192 台阶问题
- 2022-08-01:以下go语言代码输出什么?A:panic;B:5;C:6;D:编译错误。 package main import ( “fmt“ ) func main() {
猜你喜欢

多主复制下处理写冲突(4)-多主复制拓扑
Deep Blue Academy - Handwritten VIO Homework - Chapter 2

7亿听众背后的在线音频掘金故事

如何评价最近爆红的FastAPI?

Pycharm platform import scikit-learn

直播 | 7.30 ApacheCon Asia 2022 IOT/IIOT专题,IoTDB PMC 乔嘉林担任出品人

科研笔记(五) SLAC WiFi Fingerprint+ Step counter融合定位

ADSP21489数据手册表摘要

互动投影墙深受展览展示喜爱的原因分析

批量--10---根据set数拆分文件
随机推荐
Deep Learning Basics Overfitting, Underfitting Problems, and Regularization
日本痴汉打赏女主播1.5亿,结果。。。
【每日一题】1374. 生成每种字符都是奇数个的字符串
ScholarOne Manuscripts submits journal LaTeX file and cannot convert PDF successfully!
Deep Blue Academy - Fourteen Lectures of Visual SLAM - Chapter 4 Homework
alibaba数据同步组件canal的实践整理
互动投影墙深受展览展示喜爱的原因分析
C - The Domino Effect(dfs+回溯)
C# Thread IsBackground作用
论人生自动化
MySQL存储函数详解
Batch normalization (BN) based on deep learning
多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
温暖的世界
“数字化重构系统,搞定 CEO 是第一步”
科研笔记(五) SLAC WiFi Fingerprint+ Step counter融合定位
UI自动化测试框架搭建——标记性能较差用例
micro-ros arduino esp32 ros2 笔记
吴恩达机器学习系列课程笔记——第七章:正则化(Regularization)
立方体卫星Light-1