![Serializable data class kotlin](https://cdn1.cdnme.se/5447227/9-3/7_64e61dfbddf2b36517292648.png)
Imagine that we have the following simple map-like format (similar to json or any othe serialization format, isn’t it?):
![serializable data class kotlin serializable data class kotlin](https://i.stack.imgur.com/te3QD.png)
Recently such functionality was implemented in Properties library.Īll code that you will see in this post can be found on github Let’s start! Spoiler: we will try to reimplement deserialization library for map-like format using kotlin compiler. We will try to create a deserialization library for the deserialization of our map-like format. Let’s start from the most important thing: from documentation!Īctually rialization has perfect huge guide about the serialization.īut we will try to be short and practical. Let’s have a look how this framework works and try to write our own serializer. We know a lot of different libraries for the serialization in Java,īut in Kotlin it was decided to create a common framework for the serialization In general they can be split into two main groups:īinary protocols ( pickle, protobuf and many other)Īnd protocols with a string representation like json,Ĭsv, e.t.c. There are a lot of different formats usedįor serialization. Of objects or sending these objects over the network.
![serializable data class kotlin serializable data class kotlin](https://blog.jetbrains.com/wp-content/uploads/2019/03/teamcity-kotlin-build-configuration.png)
Serialization and deserialization - are two sides of the same mechanism for storing (persisting)
![serializable data class kotlin serializable data class kotlin](https://4.bp.blogspot.com/-QHhV_8ih03o/WmspsL-YOkI/AAAAAAAAeEE/xiRPb2rRx9gtJwOcWQRXLAFxhBT44zO0gCLcBGAs/s1600/AndroidKotlinDataClassExample2.png)
Writing our own compiler plugin for serialization using Kotlin
![Serializable data class kotlin](https://cdn1.cdnme.se/5447227/9-3/7_64e61dfbddf2b36517292648.png)