-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
System.NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported. Path: $.ValueType. #91
Comments
Maybe is too late but you need to add this nuget Microsoft.AspNetCore.Mvc.NewtonsoftJson and then add builder.Services.AddControllers().AddNewtonsoftJson(); in your Program.cs or Startup.cs file. |
The original comment is related to |
We should be able to fix this by either providing a customer serializer for System.Text.Json or possibly refactoring the |
Do we need related serializer packages like we have for Ardalis.SmartEnum? |
@ardalis I would personally like serialization support for a result/array of results. |
I got this issue when I used |
I believe this can be resolved by making the Type field use an expression rather than a property with an underlying field. I will try to put up a PR with the proposed changes here shortly. |
When return result it get exception :
System.NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported. Path: $.ValueType.
---> System.NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported.
at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter
1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonConverter
1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)at System.Text.Json.Serialization.Metadata.JsonPropertyInfo
1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter
1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)at System.Text.Json.Serialization.JsonConverter
1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter
1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)public Result AddUser(AddUserRequest addUserRequest)
{
try
{
return Result.Success("test");
}
The text was updated successfully, but these errors were encountered: