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

Parsing JSON into decimals throws exception

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.11
    • Affects Version/s: None
    • Component/s: Feature Request
    • None

      Version: commit b552f5e394d2fca892d5
      Exception: System.IO.FileFormatException : Cannot deserialize Decimal from BsonType: Double

      This is more for interoperability with other JSON serializers which may serialize decimals without quotations.

      --------
      public class Doc
      {
      public decimal Value

      { get; set; }

      }

      [Test]
      public void SerializeJsonNumberAsDecimal()
      {
      var d = BsonSerializer.Deserialize<Doc>("

      { \"Value\": 1.23 }

      ");
      Assert.AreEqual(d.Value, 1.23m);
      }

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            bling Bailey Ling
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: