Java 我想用RESTAPI调用在数据库中保存电子邮件详细信息

Java 我想用RESTAPI调用在数据库中保存电子邮件详细信息,java,json,spring,rest,Java,Json,Spring,Rest,我在使用这个邮件体时遇到了一个问题,因为它很少是一个普通的字符串,所以JSON解析器给出了一个错误 { "mail":"xxx.com", "mailSubject":"Hi how are you", "mailBody":"here we can have anything rich text, html etc which we are generally writing while sending the mails" } 因此,我想更改API结构,以便我们可以

我在使用这个邮件体时遇到了一个问题,因为它很少是一个普通的字符串,所以JSON解析器给出了一个错误

{
    "mail":"xxx.com",
    "mailSubject":"Hi how are you",
    "mailBody":"here we can have anything rich text, html etc which we are generally writing while sending the mails"
}

因此,我想更改API结构,以便我们可以使用json字符串内部或json字符串外部的邮件正文。

Hi,请提供类似控制器代码的代码。如果API指定它需要json对象,则使用者必须提供有效的json对象。如果他们没有,那么您的API返回400是正确的。
{
    "mail":"xxx.com",
    "mailSubject":"Hi how are you",
    "mailBody":"here we can have anything rich text, html etc which we are generally writing while sending the mails"
}
error: {
    "errorCode": 400,
    "status": "BAD_REQUEST",
    "message": "ERR-0001: Required parameters are blank or invalid.",
    "timestamp": "29-08-2018 07:06:17",
    "Errors": [
        {
            "field": "",
            "rejectedValue": "json",
            "message": "Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value\n at [Source: java.io.StringReader@74be551a; line: I, column: 134]"
        }
    ]
}