Skip to content

Error parsing float (when Globalization is set to german) #28

@brean

Description

@brean
string json = "{\"position\": [1.312, 4.606373506565475, -2.005028074709216]}";
JSONObject obj = new JSONObject(json);
Debug.Log(obj.GetField("position")[0]);

outputs 1312.
This is a localization bug, because in Germany we use "," instead of "." as separation:

Debug.Log(System.Convert.ToSingle("1,123")); // Outputs 1,123
Debug.Log(System.Convert.ToSingle("1.123")); // Outputs 1123

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions