11

How can I make JSON.NET return a decimal instead of a double when parsing floats from JSON? (it's an object with a Dictionary<string,object> that is serialized).

I've tried writing a JsonConverter but the CanConvert method doesn't get called with a Double type in order to try and convert it. There's other code regarding overriding JsonTextReader but this doesn't seem possible in the latest versions of Json.Net.

4

1 回答 1

16

在 Json.NET 5.0 中,Newtonsoft.Json.JsonSerializerSettings类有新的属性FloatParseHandling,你可以设置这个属性值Newtonsoft.Json.FloatParseHandling.Decimal

于 2013-06-12T10:44:13.783 回答