Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal Seeparator #24

Open
wvdvegt opened this issue Jan 5, 2024 · 2 comments
Open

Decimal Seeparator #24

wvdvegt opened this issue Jan 5, 2024 · 2 comments

Comments

@wvdvegt
Copy link

wvdvegt commented Jan 5, 2024

Somehow this code seems to use the users decimal separator (in my case a comma) and thus ignoreing the . (US & as far as i know part of the JSON's standard).

Result is wind speeds are 1000 fold of what they are in the data retrieved

"speed": 11.32 thus results in the demo printing 1132 m/s/

@wvdvegt
Copy link
Author

wvdvegt commented Jan 5, 2024

Debugging a bit shows windata at line 45 of Wind.cs correctly shows dots as decimal separator, but windData.SelectToken("speed") shows {11,32} as value in the Watch window.

@wvdvegt
Copy link
Author

wvdvegt commented Jan 5, 2024

Solution (note; only tested in a country with a , as separator):

replace:

SpeedMetersPerSecond = double.Parse(windData.SelectToken("speed").ToString(), CultureInfo.InvariantCulture);

by

SpeedMetersPerSecond = windData.SelectToken("speed").Value<Double>();

thus preventing converting bwteeen double and string.

This change should be applied at all simimar code. And best to remove it for other data types as integers as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant