I have the following controller action:
[HttpGet]
public JsonpResult getTestValues(int? entityId, int? id)
{
return JsonpResult(WebResult.Success());
}
I have a AJAX call that invokes this controller and has to parse the data object returned. How can I modify the above to return the following?
{"data":[{"T1":"[email protected]","T11":"1234-1234-1234-1234"},
{"T2":"[email protected]","T22":"1234-1234-1234-1234"}]}
I need this for testing the UI framework that I am working on. Any suggestions on how to return the above hardcoded data?
Yes, you can do this using an anonymous type:
return JsonpResult {
Data = new {
data = new List<object> {
new { T1 = "[email protected]", T11 = "1234-1234-1234-1234" },
new { T2 = "[email protected]", T22 = "1234-1234-1234-1234" },
}
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With