gsala
12/12/2018, 10:31 AM@Json(name = "xx")
, the serialized string has the name of the enum member itself instead of the value passed into the annotation. Has anyone run into this problem before?ienoobong
12/12/2018, 11:12 AM@field:Json(name = "xx")
?gsala
12/12/2018, 11:23 AMienoobong
12/12/2018, 12:00 PMeric
12/12/2018, 8:01 PMeric
12/12/2018, 8:01 PMgsala
12/12/2018, 10:36 PMeric
12/13/2018, 7:31 PM@Test fun foo() {
val moshi = Moshi.Builder().build()
val adapter = moshi.adapter(HasFoo::class.java)
assertThat(adapter.fromJson("{\"foo\":\"hello\"}")!!.foo).isEqualTo(Foo.WORLD)
assertThat(adapter.toJson(HasFoo(Foo.WORLD))).isEqualTo("{\"foo\":\"hello\"}")
}
@JsonClass(generateAdapter = true)
class HasFoo(val foo: Foo)
enum class Foo {
@Json(name = "hello") WORLD
}
this passes for me. if you can make a reproducible sample, file an issue on GitHub.gsala
12/13/2018, 7:34 PM