Microsoft.Extensions.Configuration.Json 10.0.0-preview.3.25171.5
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
Microsoft.AspNetCore
|
54 |
Microsoft.Extensions.Configuration.UserSecrets
User secrets configuration provider implementation for Microsoft.Extensions.Configuration.
This package was built from the source code at https://github.com/aspnet/Extensions/tree/9bc79b2f25a3724376d7af19617c33749a30ea3a
|
33 |
Microsoft.AspNetCore.ApplicationInsights.HostingStartup
ASP.NET Core lightup integration with Application Insights.
|
17 |
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/en-us/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
|
16 |
Stackage.Aws.Lambda
Custom runtime for .NET console bootstrap
|
16 |
Microsoft.Azure.WebJobs
This package contains the runtime host components of the WebJobs SDK. For more information, please visit https://go.microsoft.com/fwlink/?linkid=2279708.
|
16 |
Microsoft.Azure.WebJobs
This package contains the runtime assemblies for Microsoft.Azure.WebJobs.Host. It also adds rich diagnostics capabilities which makes it easier to monitor the WebJobs in the dashboard. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
|
16 |
Microsoft.AspNetCore.ApplicationInsights.HostingStartup
ASP.NET Core lightup integration with Application Insights.
|
16 |
Microsoft.AspNetCore
Microsoft.AspNetCore
|
16 |
Microsoft.AspNetCore
Microsoft.AspNetCore
|
15 |
Microsoft.Extensions.Logging.AzureAppServices
Logger implementation to support Azure App Services 'Diagnostics logs' and 'Log stream' features.
|
15 |
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/8e941eb42f819adb116b881195158b3887a70a1c
|
15 |
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/2924ca229b3d6c91b7c9eded119b31dfd7aa1fef
|
15 |
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/d6f154cca3863703cf87c8b840eea9cbe20229b2
|
15 |
Microsoft.Azure.WebJobs
This package contains the runtime assemblies for Microsoft.Azure.WebJobs.Host. It also adds rich diagnostics capabilities which makes it easier to monitor the WebJobs in the dashboard. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
|
15 |
.NET Framework 4.6.2
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- System.Text.Json (>= 10.0.0-preview.3.25171.5)
.NET Standard 2.1
- System.Text.Json (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
.NET Standard 2.0
- System.Text.Json (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
.NET 10.0
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)
.NET 9.0
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- System.Text.Json (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)
.NET 8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.0-preview.3.25171.5)
- System.Text.Json (>= 10.0.0-preview.3.25171.5)
- Microsoft.Extensions.Configuration (>= 10.0.0-preview.3.25171.5)