Hi,
I am using WCF WebInvokeAttribute
for declarative JSON requests (DataContractJsonSerializer
),
with DataContractAttribute
/DataMemberAttribute
based serialization.
I'm using a service that supports returning JSON containing data based on different cultures. By default, this service uses en-US culture settings, which means the decimals separator will be ".".
I have a class that has a System.Double
property.
If I request data using a culture that uses "," as decimal separator, I get a SerializationException
while trying to deserialize the value for this property, when parsing the System.Double
:
"There was an error deserializing the object of type XXX. The value '1,6276' cannot be parsed as the type 'double'."
This is certainly because an invariant culture is used while parsing the Double. I hoped that setting the correct culture on the current thread would fix this, but it didn't.
So the services will break for any cultures that is not using "." as decimal separator.
Will appreciate help.
Thanks!