Reputation: 31313
I want to control what properties are sent in my Json result.
Given...
public class Result
{
public string SendThisProperty { get; set; }
public string DontSendThisProperty { get; set; }
}
public virtual ActionResult Index()
{
var result = new Result();
return Json(result);
}
Is there a way to only return the property 'SendThisProperty'?
Upvotes: 1
Views: 47
Reputation: 4001
Add a [ScriptIgnore]
to the property declarations that you don't want in the json, that should do the trick
Upvotes: 2