I have some parameters in app.config
file of my project.
I want to do these parameters as simple as possible for customers
<add key="name" value="Incognito"/>
<add key="emails[0].type" value="Personal"/>
<add key="emails[0].email" value="abc@abc.com"/>
I need to do JSON from these parameters.
For now I use Dictionary
var parameters = new Dictionary<string, string>();
for (int i = 0; i < settings.Count; i++)
{
parameters.Add(settings.GetKey(i), settings[i]);
}
var jsonData = JsonConvert.SerializeObject(parameters);
In that case I have in result:
{ "name": "Incognito", "emails[0].type": "Personal", "emails[0].email": "abc@abc.com" }
But I want to see usual JSON array:
{ "name": "Incognito", "emails": [{"type": "Personal", "email": "abc@abc.com"}, {...}] }
How can I do that? How serialize it properly? Or maybe you know a way to write data in app.config
in human readable format?