• elizarov

    elizarov

    4 years ago
    On the other hand, if
    MyData
    is
    @Serializable
    , then it opens the road to many formats at once. You can
    JSON.stringify(obj)
    or you can
    ProtoBuf.dump(obj)
    and to parcel it you’ll have to have some kind of a helper
    Parceller
    class and use it like
    Parceller.writeTo(parcel, obj)
    . You will not be able just to do
    parcel.writeValue(obj)
    , because a serializable object does not implement
    android.os.Parcelable
    ,
    elizarov
    gildor
    +1
    4 replies
    Copy to Clipboard
  • j

    jkbbwr

    4 years ago
    Note that we are using proto2 semantics, where all fields are explicitly required or optional.
    Its a shame, would proto3 not be a better target?
    j
    elizarov
    +1
    4 replies
    Copy to Clipboard
  • karelpeeters

    karelpeeters

    4 years ago
    Continuing this discussion.
    karelpeeters
    b
    2 replies
    Copy to Clipboard
  • elizarov

    elizarov

    4 years ago
    @karelpeeters Yes. It is possible write a “JS” format implementation that does exactly what you describe. We are considering to include in some future update.
    elizarov
    karelpeeters
    +1
    11 replies
    Copy to Clipboard
  • karelpeeters

    karelpeeters

    4 years ago
    Hmm why would
    fun main(args: Array<String>) {
    println("Hello World!")
    println(JSON.plain.stringify(Foo("Hey")))
    }
    
    data class Foo(val foo: String)
    throw a
    ClassCastException: Illegal cast
    ? I'm using Kotlin-JS, so I don't have a stacktrace.
    karelpeeters
    1 replies
    Copy to Clipboard