adding support for number and boolean when using custom tag objects #722
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve handling of numbers and booleans in custom tags
Description
This PR enhances the YAML dumper to correctly handle numbers and booleans when using custom tags. Previously, these types were being converted to strings prematurely, leading to undesired quoting in the YAML output. The changes ensure that numbers and booleans retain their original type representation in the dumped YAML.
Changes in Output
Before this change, numbers and booleans in custom tags were being quoted in the YAML output:
After this change, the output correctly represents numbers and booleans without quotes:
This improvement allows for more accurate type preservation and easier parsing of the resulting YAML.
Changes
Modified the
writeNode
function to properly handleNumber
andBoolean
types:Added a new test case to verify the correct handling of numbers and booleans with custom tags:
Motivation
This change is necessary to ensure that YAML output accurately represents the original data types when using custom tags. It's particularly important for configurations and data serialization where preserving the exact type of values is crucial.
Testing
A new test case has been added to verify the correct behavior. The test ensures that numbers and booleans are dumped without quotes when using custom tags.
Additional Notes
Please review and let me know if any further changes or clarifications are needed.