I have a csv file that contains paths and values in the following format:
path;value
prop1.prop2.1;hello
prop1.prop2.2;world
prop1.prop2.3;!
prop1.prop3.test;hi
prop1.prop4;value
And I wand to get it as json:
{
"prop1": {
"prop2": {
"1": "hello",
"2": "world",
"3": "!"
}
"prop3": {
"test": "hi"
}
"prop4": "value"
}
}
I've parsed csv file like this:
Dictionary<string, string> dict = new Dictionary<string, string>();
while (csv.Read())
{
string path = csv.GetField<string>(0);
string value = csv.GetField<string>(1);
dict.Add(path, value);
}
Could you help me with method, that will create JSON from this dictionary using JSON.Net Library. Of course properties in original file can be different.