NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.16k stars 1.47k forks source link

JavaScriptSerializer.Deserialize<T> does not handle dictionaries on 2.0 #2970

Open fuzzykiller opened 5 years ago

fuzzykiller commented 5 years ago

Prerequisites

Description

After upgrading to Nancy 2.0 (from 1.4.4), suddenly the binding mechanism no longer deserializes to Dictionary<string, string>. The dictionary is created, but remains empty.

Steps to Reproduce

var dict = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(@"{""data1"": ""hello"", ""data2"": ""world"" }");
Assert.AreEqual(2, dict.Count);

Works on 1.4, does not work on 2.0. This affects calling the Bind extension methods.

System Configuration


I am not entirely sure whether this is a bug, an intended change or an approved trade-off to simplify the JSON parser. If it won’t be fixed, it should at least be mentioned in the 2.0 upgrade guide.