Jason Ankers

    Jason Ankers

    1 year ago
    With kotlinx-serialization, I want to be able to annotate a property as
    @Ref
    and have the serializer only serialize the
    id
    property of the referenced type. Is this possible? I.e.
    data class Video(
        val name: String,
        @Ref val user: User,
    )
    
    // serialized to:
    
    {
        name: "example",
        user: {
            id: "123"
        }
    }
    e

    ephemient

    1 year ago
    I'm not sure how you expect deserialization to work, but…
    d

    dimitar_

    1 year ago
    If you don’t necessary need JSON - I wrote a library that serializes/deseeializes to binary with Amazon IoN that retains object references. https://github.com/dimitark/kotlinx-serialization-ion
    Jason Ankers

    Jason Ankers

    1 year ago
    @ephemient looks good cheers!