Space getting replaced by new line (\n) in double quoted string passed as request body in REST API

时间:2017-08-13 13:55:40

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

I have a requirement to implement regular expression that accepts space in double quotes for email address. example, "unusual email with space"@domain.com. Please note the email is double quoted and is valid email.

I am testing my api with Postman and below is my request body:

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

The request goes through and comes to my api controller but the space is replaced by new line (\n).

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

My request header contains :

Content-Type: application/json Accept-Charset: UTF-8

Can someone please help how to get the exact same string with space?

Regards, Mahendra Rathod

1 个答案:

答案 0 :(得分:0)

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