属性中的换行符 - 转义问题



有人可以给我这个谜语吗...

以下信封类的实例,电子邮件属性设置为"这是第 1 行这是第 2 行"。 实质上,emailBlurb 属性包含客户端应用程序捕获的返回的回车。

public class Envelope
{
    public string emailBlurb;
}

当序列化为 json 时,最终结果是..

{
   "emailBlurb": "This is line1\nThis is line 2".  
}

Json 规定将使用转义反斜杠传输特殊字符。到目前为止,一切似乎都很好,除了当我创建带有字面意思的消息结尾的信封时:

这是第 1 行这是第 2 行

如果我在序列化后修改 json 以将"\"替换为""DocuSign 根据需要接受回车,并且消息格式适合用户......

这是第 1
行这是第 2 行

虽然我想在需要时我可以"纠正"json序列化程序的结果,但这似乎是一个黑客。这是DocuSign服务接收端的错误吗?

JSON.net 是有问题的序列化程序,如果有兴趣的话。

你不需要在简介中转义,见下面的结果和例子:

Test for basic docx a 
   line break in the blurb

样本:

--AAA
Content-Type: application/json
Content-Disposition: form-data
{
    "emailBlurb": "Test for basic docx a 
    line break in the blurb",
    "emailSubject": "Test for docx with
    a line break in the subject",
    "status": "sent",
    "compositeTemplates": [
        {
            "inlineTemplates": [
                {
                    "sequence": "1",
                    "documents": [
                        {
                            "documentId": "1",
                            "name": "basic.docx"
                        }
                    ],
                    "recipients": {
                        "signers": [
                            {
                                "recipientId": "1",
                                "name": "David W Grigsby",
                                "email": "youremail@yourdomain.com",
                                "defaultRecipient": "true",
                                "tabs": {
                                    "signHereTabs": [{
                                    "anchorString": "\Signhere\",
                                    "tabLabel": "Sign Here 1"
                                    }]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}
--AAA
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: file; filename="basic.docx"; documentid=1
Content-Transfer-Encoding: base64
UEsD

最新更新