.net core miniapi 中序列化datatable问题

发布时间 2023-08-31 11:22:53作者: devgis
> Minimal api序列化引擎问题
 
> 输出datable的时候就会出现以下错误:

An unhandled exception occurred while processing the request.

NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported.

System.Text.Json.Serialization.Converters.UnsupportedTypeConverter<T>.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)

NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported. Path: $.Data.Columns.DataType.

System.Text.Json.ThrowHelper.ThrowNotSupportedException(ref WriteStack state, NotSupportedException ex)

 

> > .netcore Minimal api中使用的是System.Text.Json 的是 不支持 Datable的序列化,但是minimalapi中似乎不能把序列化引擎替换为Newtonsoft.Json。

> > 使用builder.Services.AddControllers().AddNewtonsoftJson(options => {});在Minimal api中是不起作用的。