Created
December 17, 2012 15:35
-
-
Save JuanjoFuchs/4319174 to your computer and use it in GitHub Desktop.
Very small extension to easily convert a Json ActionResult into the object it represents.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
public static class WebExtensions | |
{ | |
public static T ToJson<T>(this ActionResult actionResult) | |
{ | |
var jsonResult = (JsonResult)actionResult; | |
return (T)jsonResult.Data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage example: