Hello :wave: I got an endpoint that can accept eit...
# spring
d
Hello 👋 I got an endpoint that can accept either a single item or a list of items. Was wondering whether there is a "better" way to do this than the below
Copy code
val rawBodyContent = serverRequest.bodyToMono(String::class.java).awaitFirst()
val jsonNode = objectMapper.readTree(rawBodyContent)
if (jsonNode.isArray) {
    objectMapper.convertValue(jsonNode, object: TypeReference<List<MyItem>>() {})
} else {
    objectMapper.treeToValue(jsonNode, MyItem::class.java)
}
looks like i can just do
bodyToMono(JsonNode::class.java)
and skip extra
String
->
JsonNode
conversion