K
K
Kirito Asumo2017-01-08 12:43:01
JSON
Kirito Asumo, 2017-01-08 12:43:01

How to parse yaml in c# and convert it to json or some kind of array?

Tried using YamlDotNet but it didn't help. Although everywhere it is sent to him. I didn't even understand how to use it.
I found an example on the Internet for converting YAML to Json.NET, but I did not understand how to get json itself.

String StringFile = File.ReadAllText(FileName);
   StringReader FileYaml = new StringReader(StringFile);

   var deserializer = new Deserializer();
   var yamlObject = deserializer.Deserialize(FileYaml);

   var serializer = new Newtonsoft.Json.JsonSerializer();
   serializer.Serialize(Console.Out, yamlObject);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2017-01-08
@Sparkis

1. var yamlObject = deserializer.Deserialize(FileYaml); deserializes yaml into some object
2. serializer.Serialize(Console.Out, yamlObject); - serializes some object into json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question