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

Unable to use JSON-syntax after upgrade to 9.1.0 #556

Closed
galvesribeiro opened this issue Jan 4, 2021 · 2 comments
Closed

Unable to use JSON-syntax after upgrade to 9.1.0 #556

galvesribeiro opened this issue Jan 4, 2021 · 2 comments

Comments

@galvesribeiro
Copy link

galvesribeiro commented Jan 4, 2021

Hello folks!

We've being using YamlDotNet 7.x.x for a while and never had an issue. We are now trying to update it to latest package because some new dependencies we have requires it. However, when we upgrade it to 9.1.0 it fail to deserialize an YAML that was working just fine.

Here is the snipped:

  player:
    - {name: "John Doe" , level: 2}

(Line: 2576, Col: 5, Idx: 76905) - (Line: 2576, Col: 5, Idx: 76905): Exception during deserialization

All we get from the exception is that.

   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.DeserializeHelper(Type tKey, Type tValue, IParser parser, Func`3 nestedObjectDeserializer, IDictionary result)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.DeserializeHelper(Type tKey, Type tValue, IParser parser, Func`3 nestedObjectDeserializer, IDictionary result)
   at YamlDotNet.Serialization.NodeDeserializers.DictionaryNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
   at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
   at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
   at YamlDotNet.Serialization.Deserializer.Deserialize[T](IParser parser)
   at YamlDotNet.Serialization.Deserializer.Deserialize[T](TextReader input)
   at YamlDotNet.Serialization.Deserializer.Deserialize[T](String input)

<REDACTED>

As I said, it worked without problem before the upgrade and if we revert back to 7.x.x I can confirm it works just fine.

Can anyone advise on what is going on?

Thanks!

@galvesribeiro galvesribeiro changed the title Unable to use JSON-syntax after upgrade Unable to use JSON-syntax after upgrade to 9.1.0 Jan 4, 2021
@galvesribeiro
Copy link
Author

We've found the issue. In fact the JSON snipped I've posted is not a valid JSON.

Changing it to this worked right away:

  player:
    - {"name": "John Doe" , "level": 2}

The fact still stand. Even with the invalid JSON, the version 7.0.0 was able to deserialize it, while 9.1.0 can't.

I'll leave the issue open so the maintainers can decide whether or not they want to fix that.

Thanks!

@EdwardCooke
Copy link
Collaborator

I just checked this with the most recent version and it is working:

using YamlDotNet.Serialization;

var yaml = @"player:
  - {name: ""John Doe"" , level: 2}
";
var deserializer = new DeserializerBuilder().Build();
var result = deserializer.Deserialize<object>(yaml);
var serializer = new SerializerBuilder().Build();
var s = serializer.Serialize(result);
Console.WriteLine(yaml);
Console.WriteLine("====");
Console.WriteLine(s);

Result

player:
  - {name: "John Doe" , level: 2}

====
player:
- name: John Doe
  level: 2

I'm going to close this issue since it doesn't look like a problem any more.

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