New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json Decimal Separator #137
Comments
Hi @muratyuceer, That's a good question. In this particular case the library defines a This is using What all of this means is that, in order to support different cultures for things like parsing numbers, we actually need to look inside the I don't know off of the top of my head how to customise the parsing culture of On a more general note, I personally don't love the way that the I actually wrote an alternative binder called |
Hi @Choc13 Thank you for the detailed explanation; I asked the question to the right person, and you've even published a package related to it :). To prevent unexpected errors, I use this method along with the following https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-8.0#validateonstart it helps to proactively address some potential runtime errors (For instance, I make every type nullable and add the required attribute). I'm considering writing a code similar to this
to filter out values with a type of decimal when binding to the model. I will add this code; I'm just researching the exact right place to include it. However, I'm also curious about your opinion. |
Yes It depends on what you're exactly trying to do here. Are you trying to parse numbers that use |
Hi @Choc13 Actually, my goal is as follows: In settings files like appsettings or Consul, someone might have defined a value like TransactionLimit: 10,50 or TransactionLimit: 10.50, and if the class property to which this value will be bound is of type decimal, I want to replace these values first with the CurrentCulture decimal separator to avoid errors. |
Hi,
How can I determine the decimal separator without overriding the global culture when deserializing JSON? As a matter of fact, I am asking to learn the most elegant approach to this question, thanks.
The text was updated successfully, but these errors were encountered: