Problem serializing decimal

Hello folks!

I’m trying to serialize an Event type which has a decimal property with the value set as 0.00000000714. Both System.Text.Json and JSON.Net works perfectly fine serializing and deserializing it however, when I send the byte[] data as the event payload, EventStoreDB persist it in the wrong way and while reading the event, it is all set to 0.

I’ve then tried to create the event directly from the portal and here is what I got:


  "TotalEarnings": 0.00000000714

What is persisted:

  "TotalEarnings": 7.14E-09

So clearly it is not a problem on our client serializing the number but instead, the way `decimals are persisted as the same behavior happens from the portal.

Any way to workaround this while a real fix comes out? That problem happens on both the ES Cloud and the local ES DB.

Any help would be appreciated.


This is a problem with json in general. If you want to preserve the decimal you need to store it as a string.

1 Like

That is weird. I can serialize it properly with System.Text.Json and JSON.Net… I wonder what makes it different. Ok, will have to workaround it with [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)].