-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathYamlParser.cs
More file actions
33 lines (29 loc) · 806 Bytes
/
Copy pathYamlParser.cs
File metadata and controls
33 lines (29 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace Spoomples.Extensions.WildcardImporter
{
using System.Collections.Generic;
using Newtonsoft.Json;
using YamlDotNet.Serialization;
public class YamlParser
{
private readonly IDeserializer _deserializer;
public YamlParser()
{
_deserializer = new Deserializer();
}
public Dictionary<string, object> Parse(string yamlContent)
{
return _deserializer.Deserialize<Dictionary<string, object>>(yamlContent);
}
public static string SerializeObject(object obj)
{
try
{
return JsonConvert.SerializeObject(obj, Formatting.Indented);
}
catch
{
return obj.ToString();
}
}
}
}