我从SNS的主题,我相信接受JSON反弹JSON SNS通知是不正确的如何正确地分析SES在Java中
{
"Type":"Notification",
"MessageId":"message-id-is-this",
"TopicArn":"bouncer.topic.name.here",
"Message":"{\"notificationType\":\"Bounce\",\"bounce\":{\"bounceType\":\"Permanent\",\"bounceSubType\":\"General\",\"bouncedRecipients\":[{\"emailAddress\":\"[email protected]\",\"action\":\"failed\",\"status\":\"5.1.1\",\"diagnosticCode\":\"smtp; 550 5.1.1 user unknown\"}],\"timestamp\":\"2017-04-24T12:58:05.716Z\",\"feedbackId\":\"feedback.id.is.here\",\"remoteMtaIp\":\"192.168.10.1\",\"reportingMTA\":\"dsn; smtp.link.here\"},\"mail\":{\"timestamp\":\"2017-04-24T12:58:05.000Z\",\"source\":\"[email protected]\",\"sourceArn\":\"arn:aws:ses:us-east-1:someid:identity/[email protected]\",\"sourceIp\":\"127.0.0.1\",\"sendingAccountId\":\"sending.account.id.is.this\",\"messageId\":\"message-id-is-this\",\"destination\":[\"[email protected]\"]}}",
"Timestamp":"2017-04-24T12:58:05.757Z",
"SignatureVersion":"1",
"Signature":"signature.link",
"SigningCertURL":"certificate.link.here",
"UnsubscribeURL":"un.subscribe.link"
}
问题是与“信息”的属性,它的不是举行一个对象,是参照对象的字符串
包含
"Message":"{\"key\":\"value\"}"
代替
"Message":{"key":"value"}"
因此没有被映射到消息类
暂时我通过接收到字符串变量解决了这个问题,并然后将其转换
private String Message;
private Message objMessage;
然后
Notification noti = toObject(jsonString, Notification.class);
Message msg = toObject(noti.getMessage(), Message.class);
noti.setObjMessage(msg);
用于转化,我正在使用ObjectMapper.readValue(...)
解决此问题的正确方法是什么?