You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No support in ExpandoObject for case-insensitive #41831
A common use case of creating an ExpandoObject is based on reading XML or JSON which may be in mixed case for the same values (e.g. Pascal-cased on server, camel-cased on client). Currently there is no way, other than using obsolete methods, to configure an ExpandoObject to be case-insensitive. This means users must duplicate the code from ExpandoObject or implement a derived class from DynamicObject.
// Raw usagedynamicobj=newExpandoObject(caseInsensitive:true);obj.A=42;Debug.Assert(obj.A==42);Debug.Assert(obj.a==42);// When used by STJ deserializationvaroptions=newJsonSerializerOptions();options.PropertyNameCaseInsensitive=true;dynamicobj=JsonSerializer.Deserialize<dynamic>(@"{""A"":42}",options);Debug.Assert(obj.A==42);Debug.Assert(obj.a==42);
Implementation
The internal implementation appears to support case-insensitivity.
If we get support for case-insensitive here, then it makes sense to support an ExpandoObject custom converter for System.Text.Json serialization. Without case-insensitive support, a custom converter would be somewhat broken so we likely wouldn't want to add and support that implementation.
A benefit of adding a custom converter, besides matching the casing support in JsonSerializerOptions, is to use the property naming policy.
An alternative to ExpandoObject in prototype form for System.Text.Json exists at #42097. See also Also see #29690.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
steveharter commentedon Sep 22, 2020
If we get support for case-insensitive here, then it makes sense to support an ExpandoObject custom converter for System.Text.Json serialization. Without case-insensitive support, a custom converter would be somewhat broken so we likely wouldn't want to add and support that implementation.
A benefit of adding a custom converter, besides matching the casing support in JsonSerializerOptions, is to use the property naming policy.
An alternative to ExpandoObject in prototype form for System.Text.Json exists at #42097. See also Also see #29690.
dotnet-policy-service commentedon Apr 8, 2025
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.