我在接收 json 数组时遇到问题。
发送 JSON 是:
[
{
"name": "Account 3",
"type": 2,
"active": true
},
{
"name": "Account 4",
"type": 1,
"active": true
},
{
"name": "Account 5",
"type": 0,
"active": true
}
]
错误是:
Mar 31, 2018 6:28:37 PM io.vertx.ext.web.impl.RoutingContextImplBase
SEVERE: Unexpected exception in route
io.vertx.core.json.DecodeException: Failed to decode: Cannot deserialize instance of `java.util.LinkedHashMap` out of START_ARRAY token
租户安全类:
class TenantSwitcherHandler(val vertx: Vertx) {
fun switchTenant(routingContext: RoutingContext) {
val tenantId: String? = routingContext.request().headers().get(CommonConstants.HEADER_TENANT)
if (tenantId.isNullOrEmpty()) {
routingContext.response().setStatusCode(HttpResponseStatus.UNAUTHORIZED.code()).end(ErrorMessages.CANT_FIND_X_TENANT_ID_HEADER.value())
return
} else {
vertx.eventBus().send(CommonConstants.SWITCH_TENANT, tenantId)
routingContext.next()
}
}
}
执行 routingContext.next() 时出错...我该如何解决这个问题?
PS:注册为Security handler的TenantSwitcherHandler类,根据X-TENANT-ID头值切换指向数据库的指针