[Fork] https://stackoverflow.com/questions/57912334

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
					
public class Program
{
	public static void Main()
	{
		var myClass = new MyClass
		{
			CamelCaseThis = new Dictionary<string, ICollection<string>>
			{
				{ "ABC1", new List<string> { "FOO", "Bar" } },
				{ "DEF2", new List<string> { "Baz", "QuuX" } },
				{ "ShouldBeAllLower3", new List<string> { "Blah" } },
			}
		};

		string json = JsonConvert.SerializeObject(myClass, Formatting.Indented);
		Console.WriteLine(json);
	}
}

[JsonObject(NamingStrategyType = typeof(CustomNamingStrategy))]
public class MyClass
{
    public Dictionary<string, ICollection<string>> CamelCaseThis { get; set; }
}

public class CustomNamingStrategy : CamelCaseNamingStrategy
{
    public CustomNamingStrategy()
    {
        ProcessDictionaryKeys = true;
        ProcessExtensionDataNames = true;
        OverrideSpecifiedNames = true;
    }

    public override string GetDictionaryKey(string key)
    {
        return key.ToLower();
    }
}
;