Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal separator in ASP.NET Core Web Api

Separator in current culture set as ",", but json data convert value with dot only. Also data controller return have dot as separator. How i can change it? I also want the comma to be invalid.

like image 491
Mihail Avatar asked May 02 '26 22:05

Mihail


1 Answers

JSON is about data, not how that data should be displayed. Regardless of culture, in both C# and JavaScript, decimals use a period as the precision separator. As such, you'd either need to transfer the formatted value as plain string (in which case you have no validation), or the value in your JSON needs to conform with expected data format of C#/JavaScript. Client-side, you can format it to/from the correct culture display.

like image 120
Chris Pratt Avatar answered May 05 '26 10:05

Chris Pratt