aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
858 stars 354 forks source link

JsonResult didn't respect the ValueTuple names #180

Closed ghost closed 6 years ago

ghost commented 6 years ago
    public (string name, string email) Foo()
    {
        return (name: "Anirudha", email: "Gupta");
    }

    public JsonResult Test()
    {
        return Json(Foo(), JsonRequestBehavior.AllowGet);
    }

when I run this code it's give me {"Item1":"Anirudha","Item2":"Gupta"} I believe that it should be name and email instead of item1 and item2.

dougbu commented 6 years ago

@anirudhagupta this is a rather significant ask because ValueTuple is not available in full .NET Framework versions before 4.7. Thus extending JsonResult to support it would require bumping our target framework way up from its current 4.5.2. We are not likely to make such a change -- back-compatibility is too important.

ghost commented 6 years ago

@dougbu no issue then.