gpt4 book ai didi

c# - 如何使用 .NET 将字符串附加到从 Blob 派生的 JSON 字符串?

转载 作者:行者123 更新时间:2023-12-03 00:41:33 25 4
gpt4 key购买 nike

我试图将一个字符串附加到从 blob 中提取的 JSON 内容中。 JSON 内容类似于下面。

    {
"Subject": "Details",
"FromAddress": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bdc5c4c7fddcdfde93ded2d0" rel="noreferrer noopener nofollow">[email protected]</a>",
"ToAddress": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90a1a2a3d0a8a9a0bef3fffd" rel="noreferrer noopener nofollow">[email protected]</a>",
"Body": "My name is {name} and I faced this {exception} error"
}

在此,我必须附加一个名称(例如 Arvind)和一个异常(例如 SystemException),并将格式化数据发送到另一个方法来发送邮件

string data = EmailBlob.DownloadTextAsync().Result;
EmailData emailData = JsonConvert.DeserializeObject<EmailData>(data);

变量data包含以下JSON

{
"Subject": "Details",
"FromAddress": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfb7b6b58faeadace1aca0a2" rel="noreferrer noopener nofollow">[email protected]</a>",
"ToAddress": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e0f0c0d7e06070e105d5153" rel="noreferrer noopener nofollow">[email protected]</a>",
"Body": "My name is {name} and I faced this {exception} error"
}

变量 emailData 包含以下内容。

  Subject: "Details",
FromAddress: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e9e8ebd1f0f3f2bff2fefc" rel="noreferrer noopener nofollow">[email protected]</a>",
ToAddress: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e3d2d1d0a3dbdad3cd808c8e" rel="noreferrer noopener nofollow">[email protected]</a>",
Body: "My name is {name} and I faced this {exception} error"

现在我必须更新名称“Arvind”和异常“SystemException”并将 emaildata 变量发送到另一个方法,如下所示。

  Subject: "Details",
FromAddress: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d0504073d1c1f1e531e1210" rel="noreferrer noopener nofollow">[email protected]</a>",
ToAddress: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5b6a69681b63626b75383436" rel="noreferrer noopener nofollow">[email protected]</a>",
Body: "My name is Arvind and I faced this SystemException error"

如何使用 C#.NET 实现它?

最佳答案

             EmailData.Body = EmailData.Body
.Replace("{name}", "Arvind")
.Replace("{exception}", "SystemException ");

关于c# - 如何使用 .NET 将字符串附加到从 Blob 派生的 JSON 字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60542798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com