1. Use vs2017 to create a single application program
2. Execute commands using the Package Manager console Install-package Microsoft.aspnetcore-version 2.0.1
3. Create a JSON file in the directory
4. The JSON file created by default will not be compiled into the bin directory, all the property pages to modify the JSON file, change the build operation to "content", copy the output directory to "always copy"
5. Run the following code to execute
usingSystem;usingMicrosoft.Extensions.Configuration;namespacejsonconfigsample{classProgram {Static voidMain (string[] args) { varBuilder =NewConfigurationbuilder (); Builder. Addjsonfile ("Json1.json"); varConfiguration =Builder. Build (); Console.WriteLine ($"name:{configuration["Name"]} age:{configuration["Age"]}"); Console.readkey (); } }}
6. Effect of execution
Using. NET core to read the JSON file configuration