Reputation: 4081
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.
Upvotes: 12
Views: 6825
Reputation: 246
In Json.NET 5.0, Newtonsoft.Json.JsonSerializerSettings
class has the new property FloatParseHandling
, you can set this property value Newtonsoft.Json.FloatParseHandling.Decimal
Upvotes: 19