Fix parsing empty Struct Values from Json (#5211)
* Fix parsing empty Struct Values from Json This fixes a bug. When parsing a struct from JSON like struct = json_format.Parse('{"k": {}}', Struct()) then the struct's "k" value would end up not initialized, and accessing the value would raise an error. In[1]: struct['k'] ValueError: Value not set That seems to be because the Struct field of the Value was not set. In[2]: struct Out[2]: fields { key: "k" value { } } This commit makes sure that the Value's Struct field is initialized even if the Struct has no values itself. This commit also extends a test to cover this case. * Additionally test for empty list
Showing
Please
register
or
sign in
to comment