LitJSON / litjson

JSON library for the .Net framework
https://litjson.net/
Other
1.37k stars 404 forks source link

Parsing decimal/float numbers on non-english culture #17

Open dheijl opened 10 years ago

dheijl commented 10 years ago

Can I propose the following change in JsonReader.cs (adding numberformatinfo):

    private void ProcessNumber (string number)
    {
        if (number.IndexOf ('.') != -1 ||
            number.IndexOf ('e') != -1 ||
            number.IndexOf ('E') != -1) {

            double n_double;
            if (Double.TryParse (number, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out n_double)) {
                token = JsonToken.Double;
                token_value = n_double;

                return;
            }
        }

In European cultures the decimal point is a comma and vice versa.

Danny

BlackMajic commented 9 years ago

Didn't see this here. A few of my users ran into the same issue, so I made pull request https://github.com/lbv/litjson/pull/37. Though my solution may be a bit overkill.