asp web api json 序列化后 把私有字段信息也返回了解决办法

 serialization returns private properties

Are your types marked as [Serializable]? Serializable means that the serializer should serialize all fields - private or public.

Try to remove Serializable or else use this line to stop the JSON formatter from recognizing the attribute:

config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver();
 
posted @ 2017-05-09 15:31  特洛伊-Micro  阅读(241)  评论(0编辑  收藏  举报