How to Ignore Null values while serializing OData response

前端 未结 3 830
甜味超标
甜味超标 2021-01-03 05:27

I\'ve a requirement to omit the null valued fields from the response altogether. I can do this by modifying the JsonFormatter Serialization Setting for a normal webapi respo

3条回答
  •  鱼传尺愫
    2021-01-03 05:45

    All the method are same I made changes to webapiconfig

    var odataFormatters = ODataMediaTypeFormatters.Create(new CustomODataSerializerProvider(), new DefaultODataDeserializerProvider());
                config.Formatters.InsertRange(0, odataFormatters);
    

    This help me to solve the result

提交回复
热议问题