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

Deserialize fails for keys with newline #684

Closed
JKostov opened this issue Apr 6, 2022 · 3 comments · Fixed by #700
Closed

Deserialize fails for keys with newline #684

JKostov opened this issue Apr 6, 2022 · 3 comments · Fixed by #700

Comments

@JKostov
Copy link

JKostov commented Apr 6, 2022

When using a complex key, that has newline char the serialization is successful but deserialization fails.

YAML example:

? >-
  key

  a

  b
: >-
  value

  a

  b

Code:

using YamlDotNet.Serialization;

var serializer = new SerializerBuilder().Build();
var deserializer = new DeserializerBuilder().Build();

var data = new Dictionary<string, string>();
data.Add("key\na\nb", "value\na\nb");

var serialized = serializer.Serialize(data);

var deserialized = deserializer.Deserialize<Dictionary<string, string>>(serialized);

The version of the YamlDotNet package that I'm using is 11.2.1.

Exception:

(Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1, Idx: 0): Exception during deserialization -> Value cannot be null. (Parameter 'key')
@EdwardCooke
Copy link
Collaborator

I'm going to see if this is even valid yaml, It still throws in the latest code, however the following works:

? >-
  key

  a

  b: >-
  value

  a

  b

Notice where the :, on the same line as b. I'll let you know what I find out.

@EdwardCooke
Copy link
Collaborator

K, it is valid, digging in to the code to determine why it's failing.

@EdwardCooke
Copy link
Collaborator

This fix will go out in the next release.

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