-
Notifications
You must be signed in to change notification settings - Fork 207
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
Coorce empty map values to null #35
Comments
Sorry had typos in original bug description. Fixed now, let me know if it's not clear. |
The 1.0 spec is totally ambiguous when it comes to handling an empty map value. There simply is zero mention of it in the entire document. In 1.1 they add the addition of ~ or "empty". I feel like it's a logical solution, since a strict type is more useful than an empty string, but with Spyc behaving this way for so long I'm not sure it's worth changing the behavior as I'm fairly certain any application still relying on it (mine included) as accounted for it. I would say this is not a bug, but still open to consensus as to how to treat it. And i know this is an old issue. But I'm trying to bring Spyc up to modern glory, since I rely on it every day with Statamic. |
well for example an empty map should be read from the yaml into an empty map and then written back to the file as an empty map. but if I try this, my empty map is turned into an empty string, which when written back, is an empty string. the correct result is, that they should remain the same, you should not be able to see any difference. so either we need a way to tell spyc to do that cause right now it does not, or consider this a bug (which I think it is) then wonder how to fix it. input file --> read into variable, immediately write into --> output file there should be no functional difference between input file and output file. |
I agree completely.
… On Nov 28, 2016, at 10:37 AM, Christopher Thomas ***@***.***> wrote:
well for example an empty map should be read from the yaml into an empty map and then written back to the file as an empty map.
but if I try this, my empty map is turned into an empty string, which when written back, is an empty string.
the correct result is, that they should remain the same, you should not be able to see any difference.
so either we need a way to tell spyc to do that cause right now it does not, or consider this a bug (which I think it is) then wonder how to fix it.
input file <-- read into variable, immediately write into --> output file
there should be no functional difference between input file and output file.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'm not a yaml expert, but it seems that there might be a bug in handling of empty map values, eg:
Here's how spyc handles it when there's tilde (by correctly print NULL):
Here's how spyc handles empty map value, should print NULL, prints empty string:
php source code: https://gist.github.com/dergachev/c2b3c18d65edf00aa8fd
I haven't read the yaml spec, I'm quite sure libyaml behaves differently.
And here's a random stack overflow thread that seems to confirm it:
http://stackoverflow.com/questions/833927/yaml-dictionary-with-empty-value
The text was updated successfully, but these errors were encountered: