Fixed #5711: serialize doesn't work with extra()

Added 'extra' argument for serialization of non-field attributes.