Microsoft.Extensions.Configuration.Json 8.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
Squadron.Core
Package Description
20
Squadron.Core
Package Description
19
Squadron.Core
Package Description
18

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

.NET Framework 4.6.2

.NET Standard 2.1

.NET Standard 2.0

.NET 8.0

.NET 7.0

.NET 6.0

Version Downloads Last updated
9.0.2 15 02/18/2025
9.0.1 14 02/18/2025
9.0.0 13 02/18/2025
8.0.1 14 02/18/2025
8.0.0 14 02/18/2025
7.0.0 13 02/18/2025
6.0.1 13 02/18/2025
6.0.0 14 06/15/2023
5.0.0 13 02/18/2025
3.1.32 13 02/18/2025
3.1.31 13 02/18/2025
3.1.30 13 02/18/2025
3.1.29 13 02/18/2025
3.1.28 13 02/18/2025
3.1.27 13 02/18/2025
3.1.26 13 02/18/2025
3.1.25 13 02/18/2025
3.1.24 13 02/18/2025
3.1.23 13 02/18/2025
3.1.22 14 02/18/2025
3.1.21 13 02/18/2025
3.1.20 13 02/18/2025
3.1.19 13 02/18/2025
3.1.18 14 02/18/2025
3.1.17 13 02/18/2025
3.1.16 13 02/18/2025
3.1.15 14 02/18/2025
3.1.14 13 02/18/2025
3.1.13 13 02/18/2025
3.1.12 13 02/18/2025
3.1.11 13 02/18/2025
3.1.10 13 02/18/2025
3.1.9 13 02/18/2025
3.1.8 13 02/18/2025
3.1.7 13 02/18/2025
3.1.6 13 02/18/2025
3.1.5 13 02/18/2025
3.1.4 14 02/18/2025
3.1.3 14 02/18/2025
3.1.2 13 02/18/2025
3.1.1 14 02/18/2025
3.1.0 14 10/08/2023
3.0.3 13 02/18/2025
3.0.2 13 02/18/2025
3.0.1 13 02/18/2025
3.0.0 13 02/18/2025
2.2.0 13 02/18/2025
2.1.1 14 02/18/2025
2.1.0 14 06/19/2023
2.1.0-rc1-final 13 02/18/2025
2.1.0-preview2-final 13 02/18/2025
2.1.0-preview1-final 14 02/18/2025
2.0.2 14 02/18/2025
2.0.1 14 02/18/2025
2.0.0 12 02/18/2025
2.0.0-preview2-final 13 02/18/2025
2.0.0-preview1-final 13 02/18/2025
1.1.2 14 02/18/2025
1.1.0 14 02/18/2025
1.1.0-preview1-final 13 02/18/2025
1.0.2 13 02/18/2025
1.0.1 13 02/18/2025
1.0.0 13 02/18/2025
1.0.0-rc2-final 13 02/18/2025
1.0.0-rc1-final 13 02/18/2025