You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
data classTest(
@JSONField(name ="Name")
varname:String = ""
)
当运行以下代码时报错
funmain(args:Array<String>) {
val pristineJson ="{\"data\":{\"lists\":[{\"Name\":\"Mark\"}]}}"val list =JSONObject.parseObject(pristineJson).getJSONObject("data").getJSONArray("lists")
for (i in list.indices) {
var sss = list.getJSONObject(i)
val single:Test= sss.toJavaObject(Test::class.java)
}
}
当转换为字符串时就不会报错
funmain(args:Array<String>) {
val pristineJson ="{\"data\":{\"lists\":[{\"Name\":\"Mark\"}]}}"val list =JSONObject.parseObject(pristineJson).getJSONObject("data").getJSONArray("lists")
for (i in list.indices) {
var sss = list.getJSONObject(i)
val single:Test=JSON.parseObject(sss.toJSONString(),Test::class.java)
}
}
The text was updated successfully, but these errors were encountered:
jelipo
changed the title
Kotlin把JSONObject转为Pojo类时,当字段首字母为大写时报错
Kotlin把JSONObject “.toJavaObject”转为Pojo类时,当字段首字母为大写时报错
Nov 26, 2017
jelipo
changed the title
Kotlin把JSONObject “.toJavaObject”转为Pojo类时,当字段首字母为大写时报错
在Kotlin对JSONObject对象使用“toJavaObject”方法转为Pojo类时,当字段首字母为大写时报错
Nov 26, 2017
Pojo
当运行以下代码时报错
当转换为字符串时就不会报错
The text was updated successfully, but these errors were encountered: