Newtonsoft.Json icon indicating copy to clipboard operation
Newtonsoft.Json copied to clipboard

Added JsonContract.TypeNameHandling property

Open TalAloni opened this issue 5 years ago • 4 comments

This PR adds JsonContract.TypeNameHandling property.

Motivation

Having JsonContract.TypeNameHandling property will allow finer control over type name serialization without having to resort to using JsonProperty which is not always possible. (classes outside the developer's control or too many classes)

Background

During a migration of large project spanning hundreds of DTOs to Newtonsoft.Json, I wished to avoid array types from being serialized with type information, while at the same time have object types serialized with type information when appropriate (TypeNameHandling.Auto for object types, and TypeNameHandling.None for array types).

IMO it is not practical nor desirable to add JsonProperty to hundreds of DTOs, and the suggested property allows finer control at the JsonContract level which I believe is the most desirable approach.

TalAloni avatar Sep 05 '20 12:09 TalAloni

This is still very relevant to me and I would really like to move forward with this.

TalAloni avatar Aug 07 '21 15:08 TalAloni

This is still very relevant to me and I would really like to move forward with this.

TalAloni avatar Dec 25 '21 09:12 TalAloni

Thanks @skundlony, I would really like to move forward with this.

TalAloni avatar Aug 21 '22 13:08 TalAloni

I would really like to move forward with this.

TalAloni avatar Aug 01 '23 11:08 TalAloni