I have to send through the network a complex object which references are almost all of them Null, but I wonder about the size of this object with this null references inside.
Which is the size of a null value contained in a serialized object?
I am evaluating if it is better to change the communication protocol, sending a simpler object, at the cost of not reusing the complex one, and make several simple one for each kind of communication I have.
In some cases, the secondary intention of data serialization is to minimize the data's size which then reduces disk space or bandwidth requirements.
A null character is one byte and an unsigned int is two bytes.
You can ignore null fields at the class level by using @JsonInclude(Include. NON_NULL) to only include non-null fields, thus excluding any attribute whose value is null. You can also use the same annotation at the field level to instruct Jackson to ignore that field while converting Java object to json if it's null.
To serialize an object means to convert its state to a byte stream so way that the byte stream can be reverted back into a copy of the object. A Java object is serializable if its class or any of its superclasses implements either the java.
The null itself should be 1 byte (0x70) as seen from Object Serialization Stream Protocol
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With