-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 在使用 JSONObject.toJavaObject 反序列化 JSONObject 到带默认值的 Kotlin 类时遇到问题。#…
- Loading branch information
1 parent
e6ff30a
commit d65ca79
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/src/test/java/com/alibaba/fastjson2/issues_3100/Issue3152.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.alibaba.fastjson2.issues_3100 | ||
|
||
import com.alibaba.fastjson2.JSON | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
|
||
|
||
class Issue3152 { | ||
|
||
data class Foo(val int: Int = 1, val bar: Bar) | ||
data class Bar(val text: String) | ||
|
||
@Test | ||
fun test() { | ||
Assertions.assertEquals( | ||
Foo(1, Bar("hello")), | ||
JSON.parseObject( | ||
""" | ||
{ | ||
"bar": { | ||
"text" : "hello" | ||
} | ||
} | ||
""".trimIndent() | ||
).toJavaObject(Foo::class.java) | ||
) | ||
} | ||
} |