Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-765

DOCS: Convention for ignoring all empty collection types in serialization?

    XMLWordPrintable

    Details

      Description

      Serializing complex documents that have many optional lists results in the explicit serialization of an empty collection (i.e. []), which is a waste of space, and makes indexes unnecessarily large and clumpy.

      I have littered my classes with a bunch of "ShouldSerializeXXX" methods, which does resolve the issue, at the cost of some additional typing. But I think it would be useful to implement this as a convention. That way, it could be established as the default, and would provide a more robust way of implementing this option globally (for all collection or IEnumerable types).

      It may be possible to do currently, but I haven't figured out how to do it. I suspect that this option might by widely useful.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: