I have some JSON that I need to deserialize so I'm using JavaScriptSerializer.DeserializeObject like:
var jsonObject = serializer.DeserializeObject(line) as Dictionary<string, object>;
The problem is that the Dictionary that comes back has a case-sensitive key comparer, but I need case-insensitive. Is there some way to get back a Dictionary that is case-insensitive?
EDIT: I'd prefer not to copy the data to a new structure, since I have a lot of data and this will be costly.
Just create a new case insensitive dictionary and populate it with the current one.
[UPDATE] Test code:
The result is:
Deserializtion time: 1 min 21 sec
Dictionary creation time: 3 sec
So, the main proble is deserializtion. Dictionary creation is about 4%
I would recommend creating a new class that inherits from
Dictionary<string, object>
and in the constructor of this class, assign the case-insensitive comparer. I don't think it can be serialized to and from JSON.