Microsoft.Extensions.Configuration.Json 9.0.0-preview.6.24327.7

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
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
2,872
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
1,385
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
886
MT.PACKAGE.DATA
修改标的字段类型
440
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
324
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
291
Microsoft.AspNetCore
Microsoft.AspNetCore
290
MT.PACKAGE.UTILITY
妙探科技nuget工具包
253
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
107
MT.PACKAGE.UTILITY
妙探科技nuget工具包 1、添加日期转财务报表报告期DateTime扩展方法
93
SkyAPM.Utilities.Configuration
SkyAPM configuration extensions.
45
Microsoft.AspNetCore
Microsoft.AspNetCore
44
Microsoft.AspNetCore
Microsoft.AspNetCore
42
Microsoft.AspNetCore
Microsoft.AspNetCore
38
Microsoft.AspNetCore
Microsoft.AspNetCore
37
Microsoft.AspNetCore
Microsoft.AspNetCore
36
Microsoft.AspNetCore
Microsoft.AspNetCore
35

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

.NET Framework 4.6.2

.NET Standard 2.1

.NET Standard 2.0

.NET 9.0

.NET 8.0

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