Thanks to visit codestin.com
Credit goes to github.com

Skip to content

System.Text.Json does not support TypeConverters #38812

@MithrilMan

Description

@MithrilMan

Describe the bug

I was used to have custom TypeConverter to convert complex types from/to strings
It was working when the serializator was Newtonsoft, now that you moved to internal dotnet serializator it doesn't work anymore

To Reproduce

Create a controller that returns a class with a complex type where you implemented a TypeConverter for (and registered using TypeDescriptor.AddAttributes )
Look the result of the controller and you'll see that the output will not be serialized according to the TypeConverter but will be serialized fully as a complex object

We will close this issue if:

  • the behavior will be consistent with newtonsoft serializator behavior

Further technical details

  • tried on ASP.NET Core version 3.1

Note that using the package Microsoft.AspNetCore.Mvc.NewtonsoftJson and doing services.AddControllers().AddNewtonsoftJson() (so basically restoring newtonsoft serializator) fixes this problem (basically bypass internal json serializator)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions