{
"creditRiskData": "{\"externalQueryDate\":\"4018-11-23T19:13:19.392+03:00\"}",
"identityTypeCode": "TTN",
"identityValue": "9999999998"
}
这是我的请求,我可以在swagger
中发送但没有反斜杠,但会出错。
从请求中获取消息后,我正在使用objectmapper
解析JSON:
private LocalDate getExternalQueryDate(String creditRiskData) throws IOException {
return objectMapper.readValue(creditRiskData, CreditRiskDataDTO.class).getExternalQueryDate();
}
这是要解析的类,以便能够将JSON转换为变量:
public class CreditRiskDataDTO {
private LocalDate externalQueryDate;
public LocalDate getExternalQueryDate() {
return externalQueryDate;
}
public void setExternalQueryDate(LocalDate externalQueryDate) {
this.externalQueryDate = externalQueryDate;
}
}
从前端开始,javascript发送时没有反斜杠。像这样:
{
"creditRiskData": "{"externalQueryDate":"4018-11-23T19:13:19.392+03:00"}",
"identityTypeCode": "TTN",
"identityValue": "9999999998"
}
但是挥舞着就会出现此错误:
"fault": {
"objectErrors": [
{
"objectName": "",
"message": "JSON parse error: Unexpected character ('e' (code 101)): was expecting comma to separate Object entries; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('e' (code 101)): was expecting comma to separate Object entries\n at [Source: (PushbackInputStream); line: 2, column: 25]"
}
有什么办法解决这个问题?发送时没有反斜杠?
例如,当我从get method
获取数据时,它的显示如下:
"{\"externalQueryDate\":\"5018-11-23\",
带反斜杠。但是在Mysql
数据库中,它没有反斜杠。但是大张旗鼓的表演带有反斜杠。
得到:
CreditRisk creditRisk = creditRiskDataRepository.findByOrganisationId(organisation.getId());
return creditRisk != null ? creditRisk.getCreditRiskDataCodeBased() : null;
当我发送此邮件时:
{
"creditRiskData": {"externalQueryDate":"4018-11-23T19:13:19.392+03:00"},
"identityTypeCode": "TTN",
"identityValue": "9999999997"
}
它给出了错误
"fieldErrors": [
{
"filterName": "creditRiskInformationCodeTermBasedRequest.identityTypeCode",
"errorCode": "NotEmpty",
"objectName": "creditRiskInformationCodeTermBasedRequest",
"message": "must not be empty",
"variables": [],
"fieldName": "identityTypeCode"
},
{
"filterName": "creditRiskInformationCodeTermBasedRequest.identityValue",
"errorCode": "NotEmpty",
"objectName": "creditRiskInformationCodeTermBasedRequest",
"message": "must not be empty",
"variables": [],
"fieldName": "identityValue"
}
]