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
Serializing an object with Seq members serializes that object as empty list, even when the sequence has items in it:
import io.vavr.API.List
import io.vavr.collection.List
import io.vavr.collection.Seq
import io.vavr.gson.VavrGson
import org.junit.Test
import kotlin.test.assertEquals
class HelloTest {
private val expected: String = "{\"ints\":[1,2,3]}"
data class DataWithSeq(val ints: Seq<Int>)
data class DataWithList(val ints: List<Int>)
@Test
fun testWithSeq() { // <- fails
val data = DataWithSeq(List(1, 2, 3))
assertEquals(expected, toJson(data))
}
@Test
fun testWithList() {
val data = DataWithList(List(1, 2, 3))
assertEquals(expected, toJson(data))
}
private fun toJson(any: Any): String {
val builder = GsonBuilder()
VavrGson.registerAll(builder)
return builder.create().toJson(any)
}
}
testWithSeq fails with
org.junit.ComparisonFailure:
Expected :{"ints":[1,2,3]}
Actual :{"ints":{}}
i only tested it in kotlin not in java but since Seq seems not to be among the registered factories in Gson.factories it is probably not different there.
hi!
Serializing an object with
Seq
members serializes that object as empty list, even when the sequence has items in it:testWithSeq fails with
i only tested it in kotlin not in java but since
Seq
seems not to be among the registered factories in Gson.factories it is probably not different there.tested with
The text was updated successfully, but these errors were encountered: