This can be done using the built-in JSON library along with YamlDotNet. This was not obvious in the YamlDotNet documentation, but I found a way to do this quite simply.
var r = new StreamReader(filename);
var deserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention());
var yamlObject = deserializer.Deserialize(r);
Newtonsoft.Json.JsonSerializer js = new Newtonsoft.Json.JsonSerializer();
var w = new StringWriter();
js.Serialize(w, o);
string jsonText = w.ToString();
I was surprised that it worked as well as it did! The JSON output was identical to other web tools.
source
share