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

Parse quoted values as strings #116

Closed
yonaskolb opened this issue Mar 24, 2018 · 3 comments
Closed

Parse quoted values as strings #116

yonaskolb opened this issue Mar 24, 2018 · 3 comments

Comments

@yonaskolb
Copy link

yonaskolb commented Mar 24, 2018

Is it possible to configure Yams to parse a quoted value (single or double quotes) as a string, instead of trying to convert to an assumed Swift type?

version: "10.10" // want it to parse to "10.10" String instead of 10.1 Float

I know it's possible to use an explicit type tag as a workaround, but it would be nice to be able to just quote a value which I thought is the standard way of specifying strings in yaml.

version: !!str '10.10' // correctly parses as "10.10"

This would fix yonaskolb/XcodeGen#268

@norio-nomura
Copy link
Collaborator

Currently there is no API to change the parsing result with or without quotation marks.
It is advisable to handle types correctly by using Codable, so I tried to implement using YAMLDecoder on XcodeGen.
Since some of XcodeGen's implementation depends on [String: Any], some types can not successfully implement as Decodable. 🤔
e.g. https://github.com/norio-nomura/XcodeGen/blob/use-yaml-decoder/Sources/ProjectSpec/Settings.swift#L79-L94

@norio-nomura
Copy link
Collaborator

As I confirmed the behavior of PyYAML, it seems to be a bug that Yams guesses the type ignoring quotes.
I will change this behavior.

@yonaskolb
Copy link
Author

Fantastic, thank you @norio-nomura! 😄

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

2 participants