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
class TestFJ {
@Test
fun test() {
val str = """
{"data": {"id": "1", "name":"n1"}}
""".trimIndent()
val d1 = JSON.parseObject(str, Data2::class.java)
val data = JSON.parseObject(str)
val d2 = data.getObject("data", Data::class.java)
Assert.assertEquals(1, d1.data.id)
Assert.assertEquals(1, d2.id)
}
}
data class Data(
val id: Int = 0,
val name: String = "",
val date: Date? = null
)
data class Data2(
val data: Data
)
The text was updated successfully, but these errors were encountered:
如下所示,如果直接 JSON.parseObject()是可以自动把"1"转成int的,
但如果不定义外层的类,先解析为通用的JSONObject,再用getObject()进行局部的转换的时候,就不会做自动的转换了,同样的,@JSONField(format="")也不再起作用
The text was updated successfully, but these errors were encountered: