I have found that when upgrading from 4.0.56 to 4.5.6 the decimals in my object are all 0. Through investigation I discovered this is due to there being a comma in each decimal of the jsv. Example: "{Test:“1,234.99”}"It appears it may be due to commit: c6ec2061743a248d1a20cd7163243a39634f9926.
Could you explain what this change was for and if there is another way to fix the serialization? Why was it not done for nullable decimals?
It’s not expecting the numbers to be formatted and doesn’t serialize them as such. So they should be left in their expected state. Where did the formatted numbers come from?
The data is coming from one of our internal, non-ServiceStack, system. We can remove the formatting to fix the service we identified the issue with. The problem is that we do not know what other services this issue may occur with. We do not receive an exception as the Decimal populates as 0. The result is unexpected as it does behave the same across all data types nor nullable types.
Right now we are forced to hold off on the upgrade until we have a means to detect all affected services and correct the formatting from the request, or determine a way around this limitation by stripping the formatting from string to decimal conversions.
The ideal change would be if I could specify the NumberStyle is a currency or have it detected.
ServiceStack Serializers are designed to be resilient by default and deserialize as much as it can without error. If you want it to throw an Exception when gets a deserialization error you can configure it with:
JsConfig.ThrowOnDeserializationError = true;
The Serializers are only designed to support what it serializers so it should match the serialized output, but I’ll look into seeing if we can make it fallback to accept these formatted numbers as well.