【问题标题】:Space getting replaced by new line (\n) in double quoted string passed as request body in REST API在 REST API 中作为请求正文传递的双引号字符串中的空格被换行符 (\n) 替换
【发布时间】:2018-01-21 12:00:48
【问题描述】:

我需要实现正则表达式,该表达式接受电子邮件地址的双引号中的空格。例如,“带有空格的不寻常电子邮件”@domain.com。请注意,该电子邮件是双引号,并且是有效的电子邮件。

我正在使用 Postman 测试我的 api,下面是我的请求正文:

{"data": 
    {   "id": "#customerId",
        "type": "customer s",
        "attributes": {
          "contactInformation" : {
            "emailAddresses" :
            [
              {
                "emailAddress" : "\"unusual email with space\"@domain.com"
              }
            ]       
          }
        }
     }
}

请求通过并到达我的 api 控制器,但空格被换行符 (\n) 替换。

"\"unusual email with\nspace\"@domain.com"

我的请求标头包含:

内容类型:application/json 接受字符集:UTF-8

有人可以帮助如何获得与空格完全相同的字符串吗?

问候, 马亨德拉·拉索德

【问题讨论】:

    标签: spring api spring-mvc spring-boot postman


    【解决方案1】:

    如果你用 \u0020 或 %20 替换空格应该没问题..!

    【讨论】:

    • 谢谢卡图尔。感谢您的帮助。
    • 如果回答了您的问题,请接受它作为答案。欢呼
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2014-12-11
    • 2015-08-25
    • 2012-03-12
    • 2014-09-07
    • 2012-05-05
    相关资源
    最近更新 更多