Microsoft.Extensions.Configuration.Json 9.0.6

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
EPPlus
Create advanced Excel spreadsheets using .NET
133
EPPlus
Create advanced Excel spreadsheets using .NET
352
EPPlus
Create advanced Excel spreadsheets using .NET
439
Glimpse.Agent.AspNet
The infrastructure and extensibility points required to enable Glimpse to gather diagnostics information from ASP.NET web applications.
47
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
54
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
63
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
85
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
179
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
232
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
289
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
422
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
67
Microsoft.Extensions.Hosting
Hosting and startup infrastructures for applications.
55
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
41
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/5a4c82ec57fadddef9ce841d608de5c7c8c74446
41
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/bb01bbf4433e27289b99001b7de6a582879d1835
42
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/bc25dd5d39fd057f7cb28acb5ad4d9e925a375de
42
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/cccab50fba1c7335fdb48a735246374b5ddd7e69
43
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/cdfa43bbe0ecc13757cc6517c9a253de77c3ec56
46

https://go.microsoft.com/fwlink/?LinkID=799421

Version Downloads Last updated
10.0.0-preview.6.25358.103 2 07/17/2025
10.0.0-preview.5.25277.114 5 06/08/2025
10.0.0-preview.4.25258.110 4 05/20/2025
10.0.0-preview.3.25171.5 5 05/03/2025
10.0.0-preview.2.25163.2 11 04/01/2025
10.0.0-preview.1.25080.5 11 03/07/2025
9.0.8 0 08/04/2025
9.0.7 1 07/18/2025
9.0.6 4 06/14/2025
9.0.5 3 05/18/2025
9.0.4 5 05/03/2025
9.0.3 10 03/17/2025
9.0.2 12 03/07/2025
9.0.1 12 02/03/2025
9.0.0 14 11/18/2024
9.0.0-rc.2.24473.5 12 10/14/2024
9.0.0-rc.1.24431.7 16 09/17/2024
9.0.0-preview.7.24405.7 12 08/16/2024
9.0.0-preview.6.24327.7 14 07/11/2024
9.0.0-preview.5.24306.7 17 06/26/2024
9.0.0-preview.4.24266.19 18 05/22/2024
9.0.0-preview.3.24172.9 21 04/12/2024
9.0.0-preview.2.24128.5 23 04/12/2024
9.0.0-preview.1.24080.9 21 02/14/2024
8.0.1 16 10/11/2024
8.0.0 23 02/15/2024
8.0.0-rc.2.23479.6 19 12/26/2023
8.0.0-rc.1.23419.4 18 02/15/2024
8.0.0-preview.7.23375.6 17 02/15/2024
8.0.0-preview.6.23329.7 24 02/14/2024
8.0.0-preview.5.23280.8 20 02/15/2024
8.0.0-preview.4.23259.5 19 02/14/2024
8.0.0-preview.3.23174.8 20 01/03/2024
8.0.0-preview.2.23128.3 21 02/14/2024
8.0.0-preview.1.23110.8 20 02/14/2024
7.0.0 21 02/15/2024
7.0.0-rc.2.22472.3 19 02/15/2024
7.0.0-rc.1.22426.10 22 02/15/2024
7.0.0-preview.7.22375.6 21 02/15/2024
7.0.0-preview.6.22324.4 21 02/14/2024
7.0.0-preview.5.22301.12 21 02/15/2024
7.0.0-preview.4.22229.4 20 02/14/2024
7.0.0-preview.3.22175.4 18 02/14/2024
7.0.0-preview.2.22152.2 19 02/14/2024
7.0.0-preview.1.22076.8 20 02/15/2024
6.0.2-mauipre.1.22102.15 17 02/15/2024
6.0.2-mauipre.1.22054.8 18 02/15/2024
6.0.1 15 11/19/2024
6.0.0 100 12/08/2021
6.0.0-rc.2.21480.5 22 02/15/2024
6.0.0-rc.1.21451.13 18 02/15/2024
6.0.0-preview.7.21377.19 18 02/15/2024
6.0.0-preview.6.21352.12 18 02/15/2024
6.0.0-preview.5.21301.5 25 12/09/2023
6.0.0-preview.4.21253.7 18 02/09/2024
6.0.0-preview.3.21201.4 19 02/15/2024
6.0.0-preview.2.21154.6 18 02/15/2024
6.0.0-preview.1.21102.12 19 02/15/2024
5.0.0 21 09/09/2021
5.0.0-rc.2.20475.5 21 02/15/2024
5.0.0-rc.1.20451.14 21 02/15/2024
5.0.0-preview.8.20407.11 21 02/15/2024
5.0.0-preview.7.20364.11 22 02/15/2024
5.0.0-preview.6.20305.6 20 02/14/2024
5.0.0-preview.5.20278.1 21 02/14/2024
5.0.0-preview.4.20251.6 18 02/15/2024
5.0.0-preview.3.20215.2 20 01/24/2024
5.0.0-preview.2.20160.3 22 12/23/2023
5.0.0-preview.1.20120.4 22 02/15/2024
3.1.32 24 12/14/2023
3.1.31 23 12/17/2023
3.1.30 22 02/15/2024
3.1.29 20 12/25/2023
3.1.28 21 02/15/2024
3.1.27 24 12/22/2023
3.1.26 21 02/15/2024
3.1.25 21 02/15/2024
3.1.24 23 02/15/2024
3.1.23 20 02/15/2024
3.1.22 24 01/14/2022
3.1.21 24 02/15/2024
3.1.20 20 02/15/2024
3.1.19 23 09/15/2021
3.1.18 22 02/15/2024
3.1.17 26 12/23/2023
3.1.16 28 07/05/2021
3.1.15 20 12/24/2023
3.1.14 23 12/27/2023
3.1.13 22 02/15/2024
3.1.12 71 02/26/2021
3.1.11 21 02/15/2024
3.1.10 22 02/15/2024
3.1.9 21 02/26/2021
3.1.8 22 02/15/2024
3.1.7 22 02/15/2024
3.1.6 19 02/15/2024
3.1.5 21 12/11/2020
3.1.4 22 02/15/2024
3.1.3 20 12/23/2023
3.1.2 19 02/27/2020
3.1.1 21 12/07/2023
3.1.0 357 02/10/2020
3.1.0-preview3.19553.2 18 02/15/2024
3.1.0-preview2.19525.4 22 02/15/2024
3.1.0-preview1.19506.1 22 02/15/2024
3.0.3 20 02/15/2024
3.0.2 20 02/15/2024
3.0.1 20 02/15/2024
3.0.0 81 03/20/2020
3.0.0-rc1.19456.10 23 02/15/2024
3.0.0-preview9.19423.4 21 02/15/2024
3.0.0-preview8.19405.4 20 02/15/2024
3.0.0-preview7.19362.4 21 02/15/2024
3.0.0-preview6.19304.6 20 02/15/2024
3.0.0-preview5.19227.9 20 02/15/2024
3.0.0-preview4.19216.2 19 02/15/2024
3.0.0-preview3.19153.1 22 02/15/2024
3.0.0-preview.19074.2 20 02/15/2024
3.0.0-preview.18572.1 20 02/15/2024
2.2.0 332 06/23/2020
2.2.0-preview3-35497 21 02/15/2024
2.2.0-preview2-35157 22 02/15/2024
2.2.0-preview1-35029 18 02/15/2024
2.1.1 22 12/10/2023
2.1.0 2,788 02/11/2020
2.1.0-rc1-final 20 02/15/2024
2.1.0-preview2-final 21 02/15/2024
2.1.0-preview1-final 23 02/15/2024
2.0.2 20 02/15/2024
2.0.1 21 02/15/2024
2.0.0 18 02/15/2024
2.0.0-preview2-final 22 12/21/2023
2.0.0-preview1-final 21 02/15/2024
1.1.2 20 02/10/2020
1.1.1 22 02/13/2020
1.1.0 21 02/15/2024
1.1.0-preview1-final 24 02/15/2024
1.0.2 20 01/04/2024
1.0.1 21 12/08/2023
1.0.0 24 02/13/2020
1.0.0-rc2-final 16 12/29/2023
1.0.0-rc1-final 23 01/10/2024