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

Deserialize discriminated data to ExpandoObject

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 2.3
    • Serialization
    • None

    Description

      I'm trying to deserialize entire document that contains polymorphic collection to dynamic object.
      And I expect that my collection will contain dynamic objects but I've got concrete types.
      I've created pull request with fix and unit test.

      Example data:
      var json = "{ \"Shapes\" : [

      { \"_t\" : \"Circle\", \"Radius\" : 5 }

      ,

      { \"_t\" : \"Square\", \"Side\" : 3 }

      ] }";

      Current behavior:
      typeof(Circle) == obj.Shapes[0].GetType()
      typeof(Square) == obj.Shapes[1].GetType()

      Expected:
      typeof(ExpandoObject) == obj.Shapes[0].GetType()
      typeof(ExpandoObject) == obj.Shapes[1].GetType()

      Attachments

        Activity

          People

            Unassigned Unassigned
            anatoliy.rabchevskiy Anatoliy Rabchevskiy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: