Check for existence of fields before serializing. Fixes #9