Click here to Skip to main content
15,867,453 members
Articles / Web Development / ASP.NET / ASP.NET Core

Adding $type to System.Text.Json Serialization like in Newtonsoft for Dynamic Object Properties

Rate me:
Please Sign up or sign in to vote.
5.00/5 (8 votes)
5 Nov 2020CPOL5 min read 31.5K   6  
This article describes a technique to serialize models containing dynamic types with System.Text.Json JsonSerializer, that doesn’t support $type.
The Pro Coders team recently migrated a big project from Newtonsoft to System.Text.Json serializer and because it doesn’t support dynamic object deserialization using $type property, we implemented an approach to serialize and deserialize dynamic objects infusing ModelFullName property for explicit deserialization by the Model type.

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Pro Coders
Australia Australia
Programming enthusiast and the best practices follower

Comments and Discussions