.net 6.0 migration issue JSON serialization

Copper Contributor

We are upgrading a c# .net framework 4.7 application to .net 6.0. This server's environment provides the controllers for a react front-end system. Our front-end is not receiving the same responses as before, due to the architected change to disallow polymorphism by default in JSON serialization. As the code that does this is external to our codebase (in the framework) we have no errors. We have a tried a lot of things, and are now trying to get the old functionality with Newtonsoft instead of the System.Text.Json. We are looking for the best long-term approach. Interestingly, we removed the inheritance and replaced it with an interface, but the new JSON serializer stubbornly keeps using only the defined interface properties, and not the entire concrete class, while Newtonsoft serializes the classes as expected. I'm attaching the parallel code we used to compare the responses - the top calls Newtonsoft, the bottom is the new .net library. Even reengineering our 15-year-old code base to remove the use of inheritance is possible. Any thoughts how to get a solution to this (am I starting in the right place)?

0 Replies