return type 이 ResponseEntity 일때
<200 OK,{id=11111, senderId=trusted-server, brandId=MYBRAND, type=TEMPLATE, senderIp=192.168.0.1, templateId=1017, players=[{id=1270218, playerId=newplayer, brandId= MYBRAND, isRead=null, messageId=11111}], messageParams=[{id=745210, name=nickname, value=class, messageId=11111}, {id=745211, name=BonusAmount, value=1, messageId=11111}]},{X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], X-Application-Context=[Hermes:swagger,dev:8080], Content-Type=[application/json;charset=UTF-8], Transfer-Encoding=[chunked], Date=[Thu, 22 Nov 2018 17:27:06 GMT]}>
이런식으로 리턴된다.
이걸 Json 형식으로 바꾸려면,
Object responseEntity = messageService.sendMessageRelease(new Long(3));
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(responseEntity);
JsonNode resultObjectList = bpJsonHttpMessageConverter.getObjectMapper().readTree(json);
이때 json 값을 확인해 보면,
{
"headers" : {
"X-Content-Type-Options" : [ "nosniff" ],
"X-XSS-Protection" : [ "1; mode=block" ],
"Cache-Control" : [ "no-cache, no-store, max-age=0, must-revalidate" ],
"Pragma" : [ "no-cache" ],
"Expires" : [ "0" ],
"X-Application-Context" : [ "Hermes:swagger,dev:8080" ],
"Content-Type" : [ "application/json;charset=UTF-8" ],
"Transfer-Encoding" : [ "chunked" ],
"Date" : [ "Thu, 22 Nov 2018 17:27:06 GMT" ]
},
"body" : {
"id" : 11111,
"senderId" : "trusted-server",
"brandId" : "MYBRAND",
"type" : "TEMPLATE",
"senderIp" : "192.168.0.1",
"templateId" : 1017,
"players" : [ {
"id" : 1270218,
"playerId" : "newplayer",
"brandId" : "MYBRAND",
"isRead" : null,
"messageId" : 11111
} ],
"messageParams" : [ {
"id" : 745210,
"name" : "nickname",
"value" : "class",
"messageId" : 11111
}, {
"id" : 745211,
"name" : "BonusAmount",
"value" : 1,
"messageId" : 11111
} ]
},
"statusCode" : "OK",
"statusCodeValue" : 200
}
좋군.