Change field name on Pair

How to change the field name of Pair?

The code like this :

val distributorNotes = ArrayList<PairDistributorNotes<String, String>>()

distributorNotes.add(PairDistributorNotes("350631771", "test"))

data class PairDistributorNotes<out x, out y>(val distributor_id: x, val note: y) {
    override fun toString(): String = "($distributor_id, $note)"

and i create asReverse() with distinctBy

val dataJson = Gson().toJson(distributorNotes.asReversed().distinctBy { it.distributor_id })

Output from dataJson :


Can field a and b change to distributor_id and note ?



Not really a Kotlin question.

To stop Proguard from minifying the class, addit to your proguard file or add a @Keep annotation.
To tell Gson to use name other than the minimized name, use @SerializedName attribute on the properties.