using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public string Dsn { get; set; }
public string Uid { get; set; }
public string Pwd { get; set; }
public string ProviderName { get; set; }
public static void Test()
var file2 = "Question62111182.json";
File.WriteAllText(file2, GetJson());
string json = File.ReadAllText(file2);
var jsonObj = JsonConvert.DeserializeAnonymousType(json, new { AppSettings = default(AppSettings) });
string jsonString = JsonConvert.SerializeObject(jsonObj);
File.WriteAllText(file2, jsonString);
Console.WriteLine(File.ReadAllText(file2));
Assert.IsTrue(!File.ReadAllText(file2).Contains("\"Name\""));
""Name"": ""To be removed"",
""ProviderName"": ""System.Data.Odbc""
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];