I have two property in my class as below. One property is in capital and another one is in small.
public class Points
{
public string X { get; set; }
public string x { get; set; }
}
It compiles fine. In code, I deserialize the class value coming from the client side like this:
JavaScriptSerializer serializer = new JavaScriptSerializer();
object value = serializer.Deserialize("{X:\"Car\", x:\"car\"}", typeof(Points));
In that, I am getting the below exception:
{"Ambiguous match found."}
at
System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at
System.Type.GetProperty(String name, BindingFlags bindingAttr)
at
System.Web.Script.Serialization.ObjectConverter.AssignToPropertyOrField(Object propertyValue, Object o, String memberName, JavaScriptSerializer serializer, Boolean throwOnError)
at
System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)
at
System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
at
System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(String input, Type targetType)
Is that the JSON is deserialized as case insensitive? How can I deserialize case-sensitive?