开发者

DataAnnotation to modify serialized JSON object

Is there a way add a data attribute to a property and have it effect the j开发者_JS百科son serializer to add a function call around the property?


No, there isn't an easy way to control the json serialization process especially with things like adding function calls around some properties which could result into an invalid JSON. But if you are trying to return JSONP you could write a custom JsonpResult.


What about an action filter that looks for JSON results and modifies them. It might be a two step process:

  • on action executing: check for the attribute and set a flag if you find it

  • on action execute: if the flag has been set, tart up the result.

I am not confident about this btw :P

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜