title: How to bind configuration objects from appsettings.json to user objects correctly
body: <p>I started some basic project on .net Core 1.1,
  and I wish to map some properties from  appsettings.json to object, but I probably can't understand correct name convention or something pretty basic</p>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration" rel="nofollow noreferrer">Regarding MSDN</a> Using Options and configuration objects section,
  it is very easy to use it.
  I added next lines to appsettings.json</p>
  
  <pre><code>{
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    },
  
    "XXXOptions": {
      "X1": {
        "AppId": "11",
        "AppCode": "22"
      },
      "X2": {
        "AppId": "",
        "AppCode": ""
      }
    }
  }
  </code></pre>
  
  <p>I added custom class </p>
  
  <pre><code> public class XXXOptions
      {
          public XXXOptions()
          {
          }
          public X1 X1{ get; set; }
          public X2 X2{ get; set; }
      }
  
      public class X1
      {
          public int AppId { get; set; }
          public int AppCode { get; set; }
      }
  
      public class X2
      {
          public int AppId { get; set; }
          public int AppCode { get; set; }
      }
  </code></pre>
  
  <p>I added next code to Startup.cs</p>
  
  <pre><code>  public void ConfigureServices(IServiceCollection services)
          {
              // Adds services required for using options.
              services.AddOptions();
  
              // Register the IConfiguration instance which MyOptions binds against.
              services.Configure&lt;XXXOptions&gt;(Configuration);
  
              // Add framework services.
              services.AddMvc();
          }
  
   public class XXXController : Controller
      {
          private readonly XXXOptions _options;
          public XXXController(IOptions&lt;XXXOptions&gt; optionsAccessor)
          {
              _options = optionsAccessor.Value;
          }
  
          public IActionResult Index()
          {
              var option1 = _options.X1;
              return Content($"option1 = {option1.AppCode}, option2 = {option1.AppId}");
              return View();
          }
      }
  </code></pre>
  
  <p>optionsAccessor.Value - Value  containes null values at XXXController constructor.</p>
  
  <p>but it seems like framework show mappet values at  JsonConfigurationProvider inside of <em>Configuration</em> property</p>
  
  <p>any ideas?</p>