icubilla / jsonexserializer

Automatically exported from code.google.com/p/jsonexserializer
0 stars 0 forks source link

decimal with regional setting #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. regional settings with currency decimal separator ","
2. serialize an object with a decimal field with a value like "24.00"
3.

What is the expected output? What do you see instead?
I expect to see like:
"myvalue": 24.00,
"mynextvalue":........

I see instead:
"myvalue": 24,00,
"mynextvalue":........

and of course there is a javascript error during the parsing

What version of the product are you using? On what operating system?
windows XP, IIS 5.1 or Visual studio 2010

Please provide any additional information below.
I made this change in ExpressionWriter.cs:
                case TypeCode.Decimal:
                    jsonWriter.WriteSpecialValue(((decimal)value).ToString(CultureInfo.InvariantCulture));
                    break;

my email is "sylvain.pointeau@gmail.com" if you need to contact me.

Best regards,
Sylvain

Original issue reported on code.google.com by sylvain....@gmail.com on 28 May 2011 at 3:48

GoogleCodeExporter commented 9 years ago
Can you give me an example of how you're calling the code and what culture 
you're in?  This should work.  You can see an example of this in 
JsonExSerializerTests\LocalizationTests.cs.  Also the WriteValue method for 
doubles in JsonWriter looks like this:
{{{
        public virtual IJsonWriter WriteValue(double value)
        {
            PreWrite(OpType.OpValue);
            _writer.Write(value.ToString("R", culture));
            return this;
        }
}}}
and culture here is the InvariantCulture.

Original comment by elliott....@gmail.com on 28 May 2011 at 5:00

GoogleCodeExporter commented 9 years ago
the culture was French with decimal separator "," and currency decimal 
separator ","

and the type of the field should be "decimal" not double or float.
I agree with you, it works for double and float, but not for "decimal"

Original comment by sylvain....@gmail.com on 28 May 2011 at 10:55

GoogleCodeExporter commented 9 years ago
Ok, somehow I missed the decimal type in your description.

Original comment by elliott....@gmail.com on 31 May 2011 at 1:35

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r278.

Original comment by elliott....@gmail.com on 31 May 2011 at 1:57