• Leon Barrett's avatar
    Fix parsing empty Struct Values from Json (#5211) · 9e69594a
    Leon Barrett authored
    * 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
    9e69594a
Name
Last commit
Last update
..
compatibility_tests/v2.5.0 Loading commit data...
google Loading commit data...
release/wheel Loading commit data...
MANIFEST.in Loading commit data...
README.md Loading commit data...
mox.py Loading commit data...
release.sh Loading commit data...
setup.cfg Loading commit data...
setup.py Loading commit data...
stubout.py Loading commit data...
tox.ini Loading commit data...