I recently upgraded my project from .NET 5 to .NET 7 and removed Newtonsoft.Json by replacing it with System.Text.Json. After the upgrade, I noticed that DateTime values in the responses of my API endpoints are different from what I expect.
For example, I expect the DateTime value "2021-05-10T11:20:54" to be returned as "2021-05-10T11:20:54", but instead, it is returned as "2021-05-10T11:20:54Z".
Previously, I was using Newtonsoft.Json with the following code:
services.AddControllers().AddNewtonsoftJson();
However, after removing Newtonsoft.Json, I'm not sure how to achieve the same behavior with System.Text.Json. How can I configure System.Text.Json to handle DateTime values in a similar way, or is there any other way to resolve this issue?
This problem also affects my Automation tests. I'm running automated tests, and this difference in DateTime values is causing failures in my tests. How can I address this discrepancy to ensure my tests pass as expected?
Any help or guidance on this issue would be greatly appreciated. Thank you!