Cannot deserialize JSON with a nested class where the first property is a Guid

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 0.11
    • Affects Version/s: 0.9
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This occurs on today's git build (8d1d29365ebefea40d2c).

      The problem only happens if the Guid is the first property of the nested type. If you swap the order of the guid and int for the Child class, it will work.

      public class Parent
      {
      public Child Child

      { get; set; }
      }

      public class Child
      {
      public Guid Id { get; set; }

      public int A

      { get; set; }

      }

      [Test]
      public void Test()
      {
      var p = new Parent

      { Child = new Child() }

      ;
      p.Child.A = 1;
      var json = p.ToJson();
      BsonSerializer.Deserialize<Parent>(json); // throws Unexpected element exception
      }

              Assignee:
              Robert Stam
              Reporter:
              Bailey Ling
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: