Aar*_*n B 2 rest response jax-rs kotlin
我正在 Kotlin 中工作,想要读取实体列表,但在 {} 上遇到语法错误:“类型不匹配,必需:类型!,找到:() -> 单位”
如果我删除 {},则 GenericType 上出现语法错误:“无法访问 'init',它在 GenericType 中受保护”
我想知道从 Kotlin 的响应中读取实体列表的正确语法是什么
val path = URL_PATH
val target = getTarget(path)
val response = getRequestBuilder(target).get()
response.readEntity(GenericType<List<FoodSummary>>() {})
Run Code Online (Sandbox Code Playgroud)
小智 6
这应该有效:
response.readEntity(object : GenericType<List<FoodSummary>>() {})
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请检查以下内容:How to create an instant of an instant of an abstract class in Kotlin?
| 归档时间: |
|
| 查看次数: |
2516 次 |
| 最近记录: |