sorry, basic questions im having trouble finding a...
# serialization
g
sorry, basic questions im having trouble finding an answer to: • kotlinx serialization plugin is inserting an annotation processor to generate code for classes annotated with
@kotlinx..Serializable
correct? • the only (?) supported way to invoke this code is with the gradle/maven plugins? theres no argument i can give
kotlinc
that will invoke the appropriate annotation preprocessors? • is there a guide that explains "so you want to add a field to an
@Serializable
class..."? How does kotlinx serialization do when I have old data and a new schema? If i use protobuf, can I get my hands on the untyped protobuf message primatives and write a migration script myself? Or similar for JSON?
j
It's a compiler plugin, not an annotation processor
You should be able to invoke it from kotlinc so long as it's on the plugin path. I don't know if it requires any arguments or not, but it'll tell you
e
Json throws on unknown fields by default but there's an option to ignore them. I haven't used the protobuf format but I expect it has that too.
if fields are missing, then they need defaults
with Json there are ways to have custom serializers operate on the JsonObject directly, not sure about Protobuf
I think you can pass a full plugin path to kotlinc? not sure, never did it before. just use Gradle
j
I'm pretty sure I've done serialization through the CLI, but it was like three plus years ago at least.