BsonDocument.ToDictionary converts an array of nested documents/arrays to an array of null values

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 1.4.1
    • Affects Version/s: 1.3.1
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If a BsonDocument contains an array of nested documents or nested arrays, calling BsonDocument.ToDictionary will convert all of the array values to null. It looks like this occurs because BsonArray.CopyTo calls each of its elements' RawValue methods, which return null for BsonDocument and BsonArray instances. I've attached a CS file with new ToDictionary and helper methods that fix this error. At the bottom of the file is the test case I used to reproduce and then correct it.

        1. ModifiedToDictionary.cs
          3 kB
          Daniel Goldman

              Assignee:
              Robert Stam
              Reporter:
              Daniel Goldman
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: