DevToys icon indicating copy to clipboard operation
DevToys copied to clipboard

JSON <> YAML tool converts JSON strings that contain numbers into YAML numbers

Open TristanSpeakEasy opened this issue 2 years ago • 1 comments

Description

Converting a JSON file that contains a number in a string field like this example:

{
  "version": "1.0"
}

will produce YAML output that changes the type of the string to a number. For example:

version: 1.0

This has caused various YAML deserializers I use to complain about unexpected types (especially when serializing into a strongly type structure that is expecting a string)

Steps To Reproduce

  1. Past the above example JSON into the JSON <> YAML Converter
  2. Observe the YAML output contains a number instead of a string for the version field
  3. Converting the received YAML back to JSON therefore does not reproduce the original JSON

Expected behavior

When converting JSON strings that contain exclusively a string that can be interpreted as a number, it retains the type of the field when converting to YAML.

The expected output for the above YAML would be:

version: "1.0"

DevToys Version

Version 1.0.10.0 | X64 | RELEASE | b949a18 | b949a18

Relevant Assets/Logs

image

TristanSpeakEasy avatar Sep 29 '22 09:09 TristanSpeakEasy