Microsoft.Extensions.Configuration.Json 9.0.0

About

JSON configuration provider implementation for Microsoft.Extensions.Configuration. This package enables you to read your application's settings from a JSON file. You can use JsonConfigurationExtensions.AddJsonFile extension method on IConfigurationBuilder to add the JSON configuration provider to the configuration builder.

How to Use

The following example shows how to read application settings from the JSON configuration file.

using System;
using Microsoft.Extensions.Configuration;

class Program
{
    static void Main()
    {
        // Build a configuration object from JSON file
        IConfiguration config = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json")
            .Build();

        // Get a configuration section
        IConfigurationSection section = config.GetSection("Settings");

        // Read simple values
        Console.WriteLine($"Server: {section["Server"]}");
        Console.WriteLine($"Database: {section["Database"]}");

        // Read a collection
        Console.WriteLine("Ports: ");
        IConfigurationSection ports = section.GetSection("Ports");

        foreach (IConfigurationSection child in ports.GetChildren())
        {
            Console.WriteLine(child.Value);
        }
    }
}

To run this example, include an appsettings.json file with the following content in your project:

{
  "Settings": {
    "Server": "example.com",
    "Database": "Northwind",
    "Ports": [ 80, 81 ]
  }
}

You can include a configuration file using a code like this in your .csproj file:

<ItemGroup>
  <Content Include="appsettings.json">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </Content>
</ItemGroup>

Additional Documentation

Feedback & Contributing

Microsoft.Extensions.Configuration.Json is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Extensions.Configuration.Json.

Packages Downloads
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
56
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
53
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
52
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
50
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
49
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
48
R4Mvc.Tools
R4Mvc is a tool that generates strongly typed helpers for ASP.NET Core MVC.
47
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
46
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
45
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
44
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
43
R4Mvc.Tools
R4Mvc is a tool that generates strongly typed helpers for ASP.NET Core MVC.
42
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
41
Microsoft.AspNetCore.NodeServices
Invoke Node.js modules at runtime in ASP.NET Core applications.
40

Version Downloads Last updated
9.0.0 2 11/13/2024
9.0.0-rc.2.24473.5 9 10/15/2024
9.0.0-rc.1.24431.7 10 9/12/2024
9.0.0-preview.7.24405.7 17 8/13/2024
9.0.0-preview.6.24327.7 22 7/10/2024
9.0.0-preview.5.24306.7 13 6/14/2024
9.0.0-preview.4.24266.19 13 5/24/2024
9.0.0-preview.3.24172.9 18 4/13/2024
9.0.0-preview.2.24128.5 18 3/14/2024
9.0.0-preview.1.24080.9 21 2/27/2024
8.0.1 11 10/22/2024
8.0.0 28 11/16/2023
8.0.0-rc.2.23479.6 30 10/17/2023
8.0.0-rc.1.23419.4 29 9/18/2023
8.0.0-preview.7.23375.6 29 8/23/2023
8.0.0-preview.6.23329.7 31 7/31/2023
8.0.0-preview.5.23280.8 32 7/31/2023
8.0.0-preview.4.23259.5 28 7/16/2023
8.0.0-preview.3.23174.8 26 5/14/2023
8.0.0-preview.2.23128.3 24 5/14/2023
8.0.0-preview.1.23110.8 29 2/24/2023
7.0.0 35 12/3/2022
7.0.0-rc.2.22472.3 33 12/3/2022
7.0.0-rc.1.22426.10 30 9/16/2022
7.0.0-preview.7.22375.6 29 5/14/2023
7.0.0-preview.6.22324.4 36 8/5/2022
7.0.0-preview.5.22301.12 34 6/27/2022
7.0.0-preview.4.22229.4 34 6/27/2022
7.0.0-preview.3.22175.4 47 6/27/2022
7.0.0-preview.2.22152.2 42 6/27/2022
7.0.0-preview.1.22076.8 38 6/27/2022
6.0.2-mauipre.1.22102.15 35 6/27/2022
6.0.2-mauipre.1.22054.8 32 6/27/2022
6.0.1 2 11/13/2024
6.0.0 32 6/27/2022
6.0.0-rc.2.21480.5 30 6/27/2022
6.0.0-rc.1.21451.13 46 6/27/2022
6.0.0-preview.7.21377.19 33 6/27/2022
6.0.0-preview.6.21352.12 32 6/27/2022
6.0.0-preview.5.21301.5 41 6/27/2022
6.0.0-preview.4.21253.7 34 6/27/2022
6.0.0-preview.3.21201.4 37 6/27/2022
6.0.0-preview.2.21154.6 32 6/27/2022
6.0.0-preview.1.21102.12 44 6/27/2022
5.0.0 34 6/27/2022
5.0.0-rc.2.20475.5 30 6/27/2022
5.0.0-rc.1.20451.14 35 6/27/2022
5.0.0-preview.8.20407.11 33 6/27/2022
5.0.0-preview.7.20364.11 39 6/27/2022
5.0.0-preview.6.20305.6 32 6/27/2022
5.0.0-preview.5.20278.1 46 6/27/2022
5.0.0-preview.4.20251.6 31 6/27/2022
5.0.0-preview.3.20215.2 34 6/27/2022
5.0.0-preview.2.20160.3 37 6/26/2022
5.0.0-preview.1.20120.4 35 6/26/2022
3.1.32 38 2/21/2023
3.1.31 34 12/3/2022
3.1.30 30 12/3/2022
3.1.29 31 2/14/2023
3.1.28 30 8/30/2022
3.1.27 29 5/14/2023
3.1.26 36 6/27/2022
3.1.25 37 6/27/2022
3.1.24 33 6/27/2022
3.1.23 30 6/27/2022
3.1.22 40 6/27/2022
3.1.21 32 6/27/2022
3.1.20 37 6/27/2022
3.1.19 36 6/27/2022
3.1.18 34 6/27/2022
3.1.17 31 6/27/2022
3.1.16 31 6/27/2022
3.1.15 36 6/27/2022
3.1.14 35 6/27/2022
3.1.13 35 6/27/2022
3.1.12 33 6/27/2022
3.1.11 41 6/27/2022
3.1.10 38 6/27/2022
3.1.9 31 6/27/2022
3.1.8 34 6/27/2022
3.1.7 30 6/27/2022
3.1.6 30 6/27/2022
3.1.5 32 6/27/2022
3.1.4 37 6/27/2022
3.1.3 33 6/27/2022
3.1.2 31 6/27/2022
3.1.1 43 6/27/2022
3.1.0 39 6/27/2022
3.1.0-preview3.19553.2 40 6/27/2022
3.1.0-preview2.19525.4 35 6/27/2022
3.1.0-preview1.19506.1 35 6/27/2022
3.0.3 38 6/27/2022
3.0.2 40 6/27/2022
3.0.1 38 6/27/2022
3.0.0 37 6/27/2022
3.0.0-rc1.19456.10 37 6/27/2022
3.0.0-preview9.19423.4 45 6/27/2022
3.0.0-preview8.19405.4 35 6/27/2022
3.0.0-preview7.19362.4 33 6/27/2022
3.0.0-preview6.19304.6 36 6/27/2022
3.0.0-preview5.19227.9 42 6/27/2022
3.0.0-preview4.19216.2 34 6/27/2022
3.0.0-preview3.19153.1 41 6/27/2022
3.0.0-preview.19074.2 35 6/27/2022
3.0.0-preview.18572.1 39 6/27/2022
2.2.0 40 6/27/2022
2.2.0-preview3-35497 37 6/27/2022
2.2.0-preview2-35157 33 6/27/2022
2.2.0-preview1-35029 37 6/27/2022
2.1.1 39 6/27/2022
2.1.0 35 6/27/2022
2.1.0-rc1-final 38 6/27/2022
2.1.0-preview2-final 30 6/27/2022
2.1.0-preview1-final 37 6/27/2022
2.0.2 35 6/27/2022
2.0.1 41 6/27/2022
2.0.0 37 6/27/2022
2.0.0-preview2-final 48 6/27/2022
2.0.0-preview1-final 36 6/27/2022
1.1.2 36 6/13/2022
1.1.1 37 6/27/2022
1.1.0 40 6/27/2022
1.1.0-preview1-final 35 6/27/2022
1.0.2 32 6/27/2022
1.0.1 36 6/27/2022
1.0.0 37 6/27/2022
1.0.0-rc2-final 29 6/27/2022
1.0.0-rc1-final 38 6/27/2022