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

Yaml to Json Conversion is using comma instead of period symbol on float values #1023

Open
LuscasLeo opened this issue Jan 10, 2024 · 1 comment
Labels
bug Something isn't working untriaged

Comments

@LuscasLeo
Copy link

Current behavior

When converting a yaml content with float props values, the json output value uses the wrong decimal separator
image

How to reproduce it (as minimally and precisely as possible)

Accessing DevToys, going on Converters and then JSON <> Yaml option, insert a value line floatvalue: 1.0

Expected behavior

Expected that the json output to follow the RFC 8259

Screenshots

image

Workaround

No response

Affected platforms

Windows

Affected DevToys kind

DevToys (app with GUI)

DevToys Version

Versão 1.0.13.0 | X64 | RELEASE | 2706c6c | 2706c6c | OS Build 22631.3007

Relevant Assets/Logs

No response

@LuscasLeo LuscasLeo added bug Something isn't working untriaged labels Jan 10, 2024
@dschonholtz
Copy link

dschonholtz commented Feb 12, 2024

Yaml to Json Conversion is using comma instead of period symbol on float values

Current behavior

When converting a yaml content with float props values, the json output value uses the wrong decimal separator

How to reproduce it (as minimally and precisely as possible)

Accessing DevToys, going on Converters and then JSON <> Yaml option, insert a value line floatvalue: 1.0

Expected behavior

Expected that the json output to follow the RFC 8259

Workaround

No response

Affected platforms

Windows

Affected DevToys kind

DevToys (app with GUI)

Relevant Code and Potential Causes

The issue with the decimal separator in float values during YAML to JSON conversion may be related to the handling of float parsing in the JsonYamlToolViewModel.cs file. The FloatParseHandling property of the JsonSerializerSettings is set to Decimal, which may not account for locale-specific decimal separators:

private readonly JsonSerializerSettings _defaultJsonSerializerSettings = new()
{
    FloatParseHandling = FloatParseHandling.Decimal
};

This setting is used in both JsonHelper.cs and YamlHelper.cs when converting between JSON and YAML. If the system's locale expects a comma as the decimal separator, this could lead to the observed behavior where the conversion process uses a comma instead of a period.

To address this issue, the conversion logic in JsonHelper.cs and YamlHelper.cs may need to be updated to ensure that the correct decimal separator is used based on the system's locale settings or to enforce the use of a period as per the RFC 8259 standard regardless of locale.

Disclaimer

Hey there,

I'm Doug, I'm a SWE working on a ticket specification bot to help get folks understanding specific bugs faster We are trying to test out our product on various open source repos like this one.

Here is what our bot churned out for this ticket. If you found it helpful or have feedback just reply to this comment, I'll be watching it. Otherwise, I just hope this is helpful. Our thing isn't ready to sell yet, but you can find more info on our website: www.AI-Maintainer.com

In the meantime, I haven't been paid to write C# in a looooonnngg time and the bot still gets stuff wrong, but looking at the code this seems at least like a decent starting point. If you could give feedback good and bad I'd love you for it. I genuinely hope this is just useful though.

As a side note, it seems like the default in Brazil, where you are from @LuscasLeo , uses a comma in the scenario you described. So this might be hard for the devs to reproduce until they switch their locale to Brazil or similar. Hence this bug not being caught previously. So you may need to adjust your locale settings locally, or the devs need to enforce consistent usage between conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

2 participants