views:

201

answers:

0

Hi there,

I've just found out little oddity in behaviour of James Newton-King's library JSON.NET. I'm using it for deserialization of client side JSON custom "features", and everything works - even validity test. Until client sends another type of "feature":

CustomJSONConverter converter=new CustomJSONConverter();
MyJSONFeature jsonFeature=JsonConvert.Deserialize<MyJSONFeature>(clientString,converter);

returns right jsonFeature if provided string is valid, correctly throws an exception when the string contains malformed JSON but incorrectly returns some object, if the string contains valid serialized feature of other type. I supposed that specifying the type, Deserialize() method should throw an exception when types aren't the same but obviously it doesn't.

Using (or using not) custom JSONConverter has no effect, it's there just for some special JSON attribute handling.

Digging through documentation didn't help very much. I'm using 3.5 version (within .NET framework 3.5, too). Did I miss something? Thanks in advance...