-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
readValue() for empty YAML returns null, not empty map #173
Comments
Case of But it is possible that existing Jackson YAML backend is handling it before. So I hope to look into this in near future to see what is going on. |
I am not sure there is something to change here: empty Map or POJO would be serialized as --- {} (or without document start indicator and empty content is parsed by SnakeYAML so that there is Stream start, Stream end events, but no Document events to indicate existence of document. |
But then it should be consistent with JSON mapper which AFAIR is not |
@damianszczepanik How so? Passing empty file to JSON will not give you equivalent of |
Appears to me it doesn't even give
Seems to me like an empty YAML should be valid. |
@rehevkor5 this is unfortunately quite tricky an area; but I would strongly suggest that anyone who needs to produce empty documents makes sure that YAML document start/separator marker ( |
When passing empty YAML file into
ObjectMapper.readValue()
thennull
is returned, not empty map.Example:
https://github.com/damianszczepanik/silencio/blob/master/src/main/java/pl/szczepanik/silencio/processors/YAMLProcessor.java#L44
Input file:
https://github.com/damianszczepanik/silencio/blob/master/src/test/resources/yaml/empty.yaml
When passing empty JSON
{}
this returns empty map so I would except to have same for YAMLThe text was updated successfully, but these errors were encountered: