Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

序列化异常 #14

Open
gubaojian opened this issue Aug 24, 2021 · 0 comments
Open

序列化异常 #14

gubaojian opened this issue Aug 24, 2021 · 0 comments

Comments

@gubaojian
Copy link
Owner

展示例子如下:

`import com.alibaba.fastjson.JSON
import kotlinx.serialization.Serializable
import java.util.*
import kotlin.collections.HashMap

@serializable
class Project(val name: String, val language: String)

//bug test
fun main(){

val map = HashMap<Any,Any>()
val user = Project("hello", "hello")

map.put(user, user)
val result = JSON.toJSONString(map)

System.out.println(result)

val back = JSON.parseObject(result)

System.out.println(back.keys.size)
back.keys.forEach {
System.out.println(it + " dd ")
}
System.out.println( " ")
}`

凡序列化异常:

Exception in thread "main" java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to java.lang.String
at JSONTestKt.main(JSONTest.kt:31)
at JSONTestKt.main(JSONTest.kt)

@gubaojian gubaojian changed the title 凡序列化异常 序列化异常 Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant