1

Jsonconverter を使用して json 文字列を逆シリアル化しようとしています。私はjson内にすべての値を持っています。また、特定のjsonがswaggerから生成されていることにも言及したいので、ペイロードをAPIに送信すると、それがオブジェクトモデルにマップされます。

ただし、同じオブジェクトに逆シリアル化しようとすると、すべてが null になります。私が間違っていることは何ですか?

これは私がそれをデシリアライズする方法です

EmailUrlDto testEmailUrlDto = JsonConvert.DeserializeObject<EmailUrlDto>(jsonString);

JSON 形式

  {
    "templateUrl": "https://some.blob.url.here.com",
    "paramsHtml": [
  {
    "name": "{{miniAdmin}}",
    "value": "Heyth is Admin!"
  },
  {
   "name": "{{cliBuTree}}",
   "value": "I`m a treeee!"
 }
 ],
 "from": "string",
 "subject": "string",
 "message": "string",
 "isHtmlBody": true,
 "recipients": [
   {
     "recipient": "some.name@lol.com"
   }
 ],
  "cCRecipients": [
    {
      "recipient": "string"
    }
  ],
  "bCCRecipients": [
    {
      "recipient": "string"
    }
  ]
}

EmailUrlDto

public class EmailUrlDto : EmailDto
{
    [Required]
    [JsonPropertyName("templateUrl")]
    public string TemplateUrl { get; set; }

    [Required]
    [JsonPropertyName("paramsHtml")]
    public ParamsHtmlTemplateDto[] ParamsHtml { get; set; }
}

メール送信先

public class EmailDto : Dto
{

    [JsonIgnore]
    public int Id { get; set; }


    [JsonPropertyName("from")]
    [MaxLength(250)]
    public string From { get; set; }


    [JsonPropertyName("subject")]
    [Required]
    [MaxLength(300)]
    public string Subject { get; set; }


    [JsonPropertyName("message")]
    [Required]
    public string Message { get; set; }


    [JsonPropertyName("isHtmlBody")]
    public bool IsHtmlBody { get; set; }


    [JsonIgnore]
    public EStatus EmlStatus { get; set; }


    [JsonPropertyName("smtp")]
    public SMTPConfigurationDto Smtp { get; set; }


    [JsonIgnore]
    public AttachmentDto[] Attachments { get; set; }


    [JsonPropertyName("recipients")]
    public ToRecipientDto[] Recipients { get; set; }


    [JsonPropertyName("cCRecipients")]
    public CcRecipientDto[] CCRecipients { get; set; }


    [JsonPropertyName("bCCRecipients")]
    public BccRecipientDto[] BCCRecipients { get; set; }


    [JsonIgnore]
    public LogDto[] Logs { get; set; }

}
4

1 に答える 1