1

I have problem with Newtonsoft.JsonConverter in my C# app. I have decimal with trailing zeros. After convert to json - there zeros are missing.

Example:

input (decimal): 1.99000
output (json): 1.99

I have my own converter, that handles decimal value. Also, I configured FloatParseHandling as decimal.

What can I do to preserve this process?

Chris Haines
  • 6,445
  • 5
  • 49
  • 62
GrzesiekO
  • 1,179
  • 4
  • 21
  • 34
  • The simplest thing you can do is ignore the decimal property during serialization (JsonIgnore attribute) and add a new readonly string one where you handle the format.Is this an option for you? – George Vovos Oct 11 '17 at 09:33
  • Possible duplicate of [Json.NET serializing float/double with minimal decimal places, i.e. no redundant ".0"?](https://stackoverflow.com/questions/21153381/json-net-serializing-float-double-with-minimal-decimal-places-i-e-no-redundant) – George Vovos Oct 11 '17 at 09:37

1 Answers1

3

This was a bug introduced in Json.NET 10.0.1 and reported here. It has since been fixed in 11.0.1.

TylerBrinkley
  • 1,066
  • 10
  • 16