Denis Bolshakov
Denis Bolshakov

Reputation: 315

Change field name in Kotlin runtime

Is it possible to change field name in Kotlin runtime? I need change filed name in my json serializator for use fild with dots (for example: "fields.field":"value")

Upvotes: 1

Views: 436

Answers (1)

Dawid Grajewski
Dawid Grajewski

Reputation: 94

What serializator are you using? In most cases it can be done using annotations. Using Moshi you can do it like that:

class SomeClass(
    @field:Json(name = "newPropertyName")
    var someProperty: String
)

Upvotes: 1

Related Questions