Empty objects
sm2017 opened this issue · 6 comments
In this proto
message MyProto {
User user = 1;
float id = 2;
}
If I create new object of MyProto and set user and empty User object , when I printDebugString , Ican see empty object in user property
But if I serializeToString and parseFromString and then printDebugString , there is no empty object and user is null
Why? How can I pass empty object ?
Could you please clarify what do you mean when you say 'empty User object'?
Assume we have this proto and compile it
message User{
string name = 1;
string family= 2;
}
the empty user object is
$user = new User;
not empty user object is
$user = new User;
$user->setName('Joe');
Any idea?
During serialization empty objects are skipped. I agree with point that you have different object state after parsing which shouldn't be the case. I will fix it.
@hjagodzinski Skipping such objects during serialization is ok unless it's a required field. This object should be recreated based on default values during parseFromString().