8000 String type loss when encoding with SingleLineStringStyle.Plain · Issue #367 · charleskorn/kaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
String type loss when encoding with SingleLineStringStyle.Plain #367
Closed
@russellbanks

Description

@russellbanks

Describe the bug

Encoding a string like "123" into Yaml when singleLineStringStyle is set to SingleLineStringStyle.Plain makes its associated type in Yaml if it wasn't a string. For example, "123" becomes 123 as an Int, "123.1" becomes 123.1 as a Float, and "true" becomes true as a Boolean. This should become quoted (single or double) when this is the case, regardless of the SingleLineStringStyle.

Reproduction repo

https://github.com/russellbanks/Komac

Steps to reproduce

  1. Create a YamlConfiguration with plain single line string style: YamlConfiguration(singleLineStringStyle = SingleLineStringStyle.Plain)
  2. Encode a string like "123" into Yaml with this configuration
  3. The string will be encoded as an an Integer rather than a String, and not escaped with quotes

Expected behaviour

# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.4.0.schema.json

PackageIdentifier: Package.Identifier
PackageVersion: "123" # or '123'
ManifestVersion: 1.4.0

Actual behaviour

# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.4.0.schema.json

PackageIdentifier: Package.Identifier
PackageVersion: 123 # Incorrect type. Expected "string". yaml-schema: https://aka.ms/winget-manifest.installer.1.4.0.schema.json
ManifestVersion: 1.4.0

Version information

0.49.0

Any other information

https://stackoverflow.com/a/22235064:

  • Use quotes to force a string, e.g. if your key or value is 10 but you want it to return a String and not a Fixnum, write '10' or "10".

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

      0