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

D-Yaml chokes on tabs when in flow style #258

Closed
schveiguy opened this issue Jul 20, 2020 · 5 comments · Fixed by #262
Closed

D-Yaml chokes on tabs when in flow style #258

schveiguy opened this issue Jul 20, 2020 · 5 comments · Fixed by #262
Milestone

Comments

@schveiguy
Copy link

The following should be a valid Yaml document (and valid JSON).

{
"root": {
	"key": "value"
    }
}

However, D Yaml chokes on it because of the leading tab before "key". The 1.1 spec states that in flow style (using braces and brackets to denote maps and arrays), leading whitespace is NOT considered indentation.

This feature is critical for DYaml to be considered a "superset" of JSON.

PyYaml, upon which this is based, also chokes on this.

@Herringway
Copy link
Member

checked with other yaml devs and confirmed that this is valid YAML. I'm not sure when I'll be able to get around to implementing this, though...

@Herringway Herringway added this to the 1.0 milestone Jul 22, 2020
@schveiguy
Copy link
Author

Just to give a bit of background, we are discussing possibly moving to YAML for dub configuration instead of (or in addition to) json. I wrote a small test program to go through all projects on code.dlang.org to find out how well dyaml would parse the various dub.json files. A surprising amount have leading tabs (over 50% of all dub.json files in all versions of projects). I was hoping to just include one parser for the config files, but dyaml doesn't support this. So even if we used YAML as a new format, we would have to keep including the json parser (the one inside dub appears to be a custom version of a json parser).

@Herringway
Copy link
Member

unfortunately, YAML 1.1 doesn't fully support JSON. it should be compatible in most simple cases already, but YAML 1.2 is the one that almost guarantees compatibility (duplicate keys are unsupported, which I don't think are usable in dub.json files anyway)

I'm still working out what needs to be done to fully support 1.2, but I'm just one person with a whole lot of other interesting projects on the table.

@schveiguy
Copy link
Author

Believe it or not, duplicate keys were present in a few projects (and DYaml choked on those too). The end result I think is that the second one wins, but it was limited to one or two projects. We are probably OK with that level of breakage.

Someone tested DYAML with some of the "incompatibilities" (spaces required after commas and colons) and said it worked. Now looking back at it, I wonder if it parsed as expected, or if it parsed into something not expected. I didn't actually test if the parsed json matched the parsed yaml, only that I got a result and not an exception.

@Herringway
Copy link
Member

there's a tojson subpackage that translates stdin from yaml to json. it might be useful for double checking.

Herringway added a commit to Herringway/D-YAML that referenced this issue Sep 19, 2020
dlang-bot pushed a commit that referenced this issue Sep 19, 2020
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

Successfully merging a pull request may close this issue.

2 participants