https://kotlinlang.org logo
#serialization
Title
# serialization
l

leandrodev

12/19/2017, 6:16 PM
Hello guys, I'm using kotlinx.serialization with a JVM project. I used the annotation
SerialName
to override properties names with custom names. But when attempting to serialize an enum object, I noticed that it doesn't work. Is there any other special annotation for enums? Another solution that I attempted was to write a custom serializer for my enum class. I've successfully implemented that, but when creating a
JSON
with
unquoted = true
, I noticed that it does not unquote only the value of my custom serializer. Is this something that implemented the wrong way?
Copy code
companion object: KSerializer<Status> {
        override fun save(output: KOutput, obj: Status) {
            output.writeStringValue(obj.description)
        }
...
s

sandwwraith

12/19/2017, 6:55 PM
it’s seems there is FR for your case here: https://github.com/Kotlin/kotlinx.serialization/issues/31
😄 1
👍 1
I don’t remember it for sure, but unquoted JSON can quote strings when they are values, and you’re writing string value there
3 Views