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
EPPlus
A spreadsheet library for .NET framework and .NET core
69
EPPlus
A spreadsheet library for .NET framework and .NET core
72
EPPlus
A spreadsheet library for .NET framework and .NET core
1,847
EPPlus
Create advanced Excel spreadsheets using .NET
66
EPPlus
Create advanced Excel spreadsheets using .NET
2,034
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
66
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
64
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
67
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
68
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
76
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration. When using NuGet 3.x this package requires at least version 3.4.
66
TNE.Common
Package Description
10,208
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
64
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
66
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
69
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
84
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
86
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
89
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
96
Winton.Extensions.Configuration.Consul
Provides support for configuring .NET Core applications with Consul
10,199

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

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