YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Cannot serialize Newtonsoft.Json deserialized object

Open jcagme opened this issue 6 years ago • 1 comments

Might be related to https://github.com/aaubry/YamlDotNet/issues/26.

I'm trying to serialize an object which was deserialized from an HTTP response using Newtonsoft.Json ans it looks like any array which was deserialized from JSON into an object fails to then be serialized into YAML.

Repro:

string array = " [\"A\",\"B\"]";
var desArray = JsonConvert.DeserializeObject<object>(array);
ISerializer serializer = new SerializerBuilder().Build();
string yamlArray = serializer.Serialize(desArray);

Produces:

- []
- []

Probably this is due to the fact the loosely typed object which is outputted after deserializing. If I actually use a type like IEnumerable<object>, it correctly serializes it to YAML.

I'm on YamlDotNet.Signed 5.3.0

jcagme avatar Feb 06 '19 00:02 jcagme