>>We can't store trailing nulls, it'll mess things up.
Okie then will rework on this.  So let me pass an information like in the above case 3 (to indicate non null elements count) and see if I could make up with that.
I am now storing the number of terminating nulls along with total array elements and using it up.  Not storing anything additional for trailing nulls. But the deserialization logic would use this terminating nulls count to see how many it has to read and what to discard.