I'm trying to create a Json object using Jackson but I can't use put because it's deprecated and will fail the pipelines checks in my company so I'm trying to use set:
fun HttpRequest.toJSONString(): String {
val mapper = ObjectMapper()
val root = mapper.createObjectNode()
val headers = mapper.createObjectNode()
this.headers().map().entries.forEach {h ->
headers.put(h.key, mapper.convertValue(h.value, JsonNode::class.java)) // its deprecated
}
root.set("headers", headers) // its failing
root.set("url_path", "https://facebook.com") // fails
return root.toString()
}
I got an error message: Not enough information to infer parameter T in operator fun <T : JsonNode!> set(p0: String!, p1: JsonNode!): T!
Please specify it explicitly.
How can I solve it?