API Decimal/Language issue (Version 12)

Vote:
 

Hi Guys

Im not a Episerver expert, but an integration partner, so basic please.

I sending a decimal number in json with dot as decimal seperator.
If there is more than 2 decimal, then danish and german is converted into thousands.

So 0.153 turns into 153, but english and frence er fine. (its also 153 in backend, so not caused by frontend)

Why is dot treated that way in these languages and what controls this behavior?

Should i format decimal diffenrently for each language og just use string?

Thanks.

Metafield payload

 {
      "Name": "NetWeight",
      "Type": "Decimal",
      "Data": [
        {
          "Language": "da",
          "Value": 0.841
        },
        {
          "Language": "de",
          "Value": 0.841
        },
        {
          "Language": "en",
          "Value": 0.841
        },
        {
          "Language": "fr",
          "Value": 0.841
        }
      ]
    }

#198143
Oct 22, 2018 19:58
Vote:
 

Hello Brian

Just a guess but I am guessing that the number if being parsed using the language locale which can of course change by country. For example in the UK the . is used as the decimal separator and , to separate 1000's. So one thousand point 56 is 1,000.56 however in Germany the . and , usage is reversed so one thousand point 56 is 1.000,5

I hope that makes sense and may go some way to explaining the behaviour. It may be worth formatting based on the langauge locale and see if that solves your problem (.net has plenty of classes to help with this). 

#198146
Oct 22, 2018 22:12
Vote:
 

Hi David

Thanks for your input. I will take it up with our Episerver partner.

#198149
Oct 23, 2018 7:35
Vote:
 

I would try to fallback to `InvariantCulture` while parsing dates, decimals, etc. the same applies for time - always try to talk in UTC..

#198383
Edited, Oct 26, 2018 8:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.