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
After writing an object with a Set of size of 0 or 1 to a json string, this json string cannot be parsed. An exception is thrown. This case works with Lists, but fails with Sets.
Here is an example test case:
fun main() {
val listTest1 = ListTest(arrayListOf("a", "b", "c"))
println(listTest1)
val listJson1 = Klaxon().toJsonString(listTest1)
println(listJson1)
val listTest2 = Klaxon().parse<ListTest>(listJson1)
println(listTest2)
assert(listTest1 == listTest2)
val listTest3 = ListTest(arrayListOf("a"))
println(listTest3)
val listJson2 = Klaxon().toJsonString(listTest3)
println(listJson2)
val listTest4 = Klaxon().parse<ListTest>(listJson2)
println(listTest4)
assert(listTest3 == listTest4)
val setTest1 = SetTest(hashSetOf("a", "b", "c"))
println(setTest1)
val setJson1 = Klaxon().toJsonString(setTest1)
println(setJson1)
val setTest2 = Klaxon().parse<SetTest>(setJson1)
println(setTest2)
assert(setTest1 == setTest2)
val setTest3 = SetTest(hashSetOf("a"))
println(setTest3)
val setJson2 = Klaxon().toJsonString(setTest3)
println(setJson2)
val setTest4 = Klaxon().parse<SetTest>(setJson2)
println(setTest4)
assert(setTest3 == setTest4)
}
data class SetTest(val set: HashSet<String>) {
override fun equals(other: Any?): Boolean {
return other is SetTest && set == other.set
}
}
data class ListTest(val list: ArrayList<String>) {
override fun equals(other: Any?): Boolean {
return other is ListTest && list == other.list
}
}
In this case, the exception thrown is Parameter set: expected kotlin.collections.HashSet<kotlin.String> /* = java.util.HashSet<kotlin.String> */ but received java.util.Collections$SingletonSet (value: [a])
The text was updated successfully, but these errors were encountered:
After writing an object with a Set of size of 0 or 1 to a json string, this json string cannot be parsed. An exception is thrown. This case works with Lists, but fails with Sets.
Here is an example test case:
In this case, the exception thrown is
Parameter set: expected kotlin.collections.HashSet<kotlin.String> /* = java.util.HashSet<kotlin.String> */ but received java.util.Collections$SingletonSet (value: [a])
The text was updated successfully, but these errors were encountered: