ansman/kotshi

Variable name with "is" as Prefix having issue. Could not find a getter named getIsVeg, annotate the parameter with @GetterName if you use @JvmName

Closed this issue · 2 comments

My dataclass

@JsonSerializable
data class VariationsDataClass(val name: String,
val price: Int,
@JSON(name = "default") val defaultValue: Int,
val id: String,
val inStock: Int,
val isVeg: Int)

gives below issue

Error:(47, 2) error: Kotshi: Could not find a getter named getIsVeg, annotate the parameter with @GetterName if you use @JvmName
java.lang.String id, int inStock, int isVeg) {

Below changes in variable name fixed it, by removing is as prefix

@JsonSerializable
data class VariationsDataClass(val name: String,
val price: Int,
@JSON(name = "default") val defaultValue: Int,
val id: String,
val inStock: Int,
@JSON(name = "isVeg") val veg: Int)

using below versions

implementation 'com.squareup.moshi:moshi:1.5.0'
implementation 'com.squareup.moshi:moshi-adapters:1.5.0'
implementation 'se.ansman.kotshi:api:1.0.2'
kapt 'se.ansman.kotshi:compiler:1.0.2'

This has been fixed in #75 but is not yet released

Released in 1.0.3