JSON.NET JObject key comparison case-insensitive

Solution 1:

This should work:

var json = @"{UPPER: 'value'}";
var jObj = JObject.Parse(json);
var upper = jObj.GetValue("upper", StringComparison.OrdinalIgnoreCase)?.Value<string>();

Console.WriteLine(upper); // value

Solution 2:

c# allows you to use dictionaries with keys that are case insensitive, so a workaround I've used is to convert the JObject to a dictionary with StringComparer.CurrentCultureIgnoreCase set, like so:

JObject json = (JObject)JsonConvert.DeserializeObject(ptString);
Dictionary<string, object> d = new Dictionary<string, object>(json.ToObject<IDictionary<string, object>>(), StringComparer.CurrentCultureIgnoreCase);

String f = d["FROM"].ToString();