ASP.NET Web API partial response Json serialization

前端 未结 3 836
失恋的感觉
失恋的感觉 2020-12-17 05:34

I am implementing a Web API that supports partial response.

/api/users?fields=id,name,age

Given the class User

[JsonObject(         


        
3条回答
  •  [愿得一人]
    2020-12-17 05:44

    Create your own IContractResolver to tell JSON.NET which properties need to be serialized. There's an example in official documentation you can take draw inspiration from.

提交回复
热议问题