Is there a way to have configuration sections written in JSON instead of XML?
Let\'s suppose I have the following ConfigurationSection
:
publ
I'm recommending to use FX.configuration, you can add it from NuGet. you can find it at: http://nugetmusthaves.com/Package/FX.Configuration
some code examples can be found at: https://bitbucket.org/friendlyx/fx.configuration
it enables you to add to the App.config stuff like: < add key="JsonConfig" value="{ 'Id': '42', 'Name': 'foo' }" />
another option when using the FX.configuration is to add a new config.json file with all your configuration and at the creation of the instance it will read and parse it.
the following code does exactly what you need with the new json config file.
using System.Collections.Generic;
using FX.Configuration;
namespace JsonConfigurationConsole
{
class Program
{
static void Main(string[] args)
{
var config = new Users();
}
}
public class Users : JsonConfiguration
{
public List users { get; set; }
}
public class User
{
public string name { get; set; }
}
}