This YAML
file:
---
- Prisoner
- Goblet
- Phoenix
---
- Memoirs
- Snow
- Ghost
is deserializing by this code:
var input = new StreamReader (path)
var deserializer = new Deserializer();
var lis = deserializer.Deserialize <List <string>> (input);
Result is Exception in YamlDotNet.dll
:
(Line: 5, Col: 4, Idx: 136): Expected 'StreamEnd',
got 'DocumentStart' (at Line: 5, Col: 1, Idx: 133).
Update1: SharpYaml: the same exception
Update2: @DarrelMiller: Yes, it is not clear from my first example, but the need of document separator is seen in second example:
---
- Prisoner
- Goblet
- Phoenix
---
- Memoirs: [213, 2004]
- Snow: [521, 2011]
- Ghost: [211, 2002]
So I needed the separator to change the type for the Deserializer
.
@AntoineAubry: Thanks for answer and YamlDotNet, I like them both.
You can easily deserialize more than one document. In order to do that, you need to use the Deserialize() overload that takes an EventReader:
Here's a fully working example.
You can even read any number of documents by using a loop:
Working example