i am trying to consume a protobuf API over json an...
# serialization
e
i am trying to consume a protobuf API over json and it uses
oneof
extensively. i originally built my data objects as just normal data classes with nullable fields representing the various oneof field options, but I’d really like to represent this with a sealed class. I started writing a custom decoder but I can’t figure out how to essentially “peek” and see which field is present so I know which serializer to use. anybody done this successfully?
the “try deserializing each of the sealed class implementations” approach doesn’t work, calling
decode
apparently moves the index and thus subsequent calls for the other types fail
except there doesn’t seem to be a
decodeJson
method anymore
it’s called
fromJson
now, wheeeee