我将以下内容json
发送到 api
{
"Id":22,
"UserId":22,
"Payload":{
"Field":"some payload value"
...more unknown field/values go here
},
"ContextTypeId":1,
"EventTypeId":1,
"SessionId":1
}
我想将其映射到以下内容:
public class CreateTrackItem : IRequest<int>
{
public int Id { get; set; }
public int UserId { get; set; }
public string Payload { get; set; }
public int ContextTypeId { get; set; }
public int SessionId { get; set; }
public int EventTypeId { get; set; }
}
当映射Payload
属性失败时,它无法映射json
到字符串,我只是希望Payload
成为一个string
版本json
(将进入一个jsonb
字段postgres
)
我正在使用 .NET Core 3.0,System.Text.Json
如果可能的话,我更喜欢在切换到Newtonsoft
.