[CSHARP-151] Parsing JSON into decimals throws exception Created: 19/Jan/11  Updated: 02/Apr/15  Resolved: 19/Jan/11

Status: Closed
Project: C# Driver
Component/s: Feature Request
Affects Version/s: None
Fix Version/s: 0.11

Type: New Feature Priority: Major - P3
Reporter: Bailey Ling Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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);
}



 Comments   
Comment by Robert Stam [ 19/Jan/11 ]

Fixed. Allow deserialization of type decimal from actual values of type double, Int32 and Int64.

Generated at Wed Feb 07 21:35:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.