2 개의 서비스, 1 application/x-www-form-urlencoded 및 string payload 및 json 본문이있는 다른 application/json 형식의 리소스를 만들려고합니다.ByteArrayOutputStream을 kotlin의 json으로 변환합니다.
이 코드가 있습니다
@POST @Path("/test")
fun test(@Context request: ContainerRequest): Response {
val baos = ByteArrayOutputStream()
request.entityStream.use { it.copyTo(baos) }
val ipnRawData = baos.toString()
var map : Map<String,Any>
map = when (request.headers.getFirst("Content-Type")) {
"application/json" -> objectMapper.convertValue(ipnRawData,Map::class.java) as Map<String,Any>
"application/x-www-form-urlencoded" -> LinkedHashMap()
else -> throw UnsupportedOperationException()
}
//....handle the map
return Response.status(200).build()
}
을하지만이 JSON 옵션을 실행하려고하고, 신체 때 어떤 도움
"java.lang.IllegalArgumentException: Can not construct instance of java.util.LinkedHashMap: no String-argument constructor/factory method to deserialize from String value ('{ "name" :"test"}')"
감사 : {"name" :"test"}
), 오류가 발생합니다 , Yoel
자세한 답변과 유용한 정보를 보내 주셔서 감사합니다. – Joel