I need to convert a yaml file to json format for validating it against a json schema. So I use yamldotnet to read the yaml file and json.net to serialize it into a string in json format. Unfortunately, after that, all numeric values are converted to string and validation goes wrong.
How can I avoid that?
Here is the code I use:
var t = File.ReadAllText(src);
var d = new YamlDotNet.Serialization.Deserializer();
var sr = new StringReader(t);
var o = d.Deserialize(sr);
var s = new Newtonsoft.Json.JsonSerializer();
var sb = new StringBuilder();
var sw = new StringWriter(sb);
s.Serialize(sw, o);
txt = sb.ToString();
Console.WriteLine("JSON Output: {0}", txt);