Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of a serialized null values

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.

like image 372
Mr.Eddart Avatar asked Dec 05 '11 10:12

Mr.Eddart


People also ask

Does serialization reduce size?

In some cases, the secondary intention of data serialization is to minimize the data's size which then reduces disk space or bandwidth requirements.

How many bytes does null have?

A null character is one byte and an unsigned int is two bytes.

How do I ignore JSON property if null?

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.

What happens if the object to be serialized?

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.


1 Answers

The null itself should be 1 byte (0x70) as seen from Object Serialization Stream Protocol

like image 106
Roger Lindsjö Avatar answered Oct 15 '22 22:10

Roger Lindsjö