I have issue when using Klaxon 5.5
Class :
data class QRResponse(
@field:SerializedName("qrType")
val qrType: String? = null,
@field:SerializedName("qrData")
val qrData: String? = null
)
Code :
val dataContents = result.contents
Log.d("ScanQRData", "result.contents : $dataContents")
val dataQR = Klaxon().parse<QRResponse>(dataContents)
Log.d("ScanQRData", "dataQR : $dataQR")
Result :
ScanQRData: result.contents : {"qrType": "product", "qrData":"352307811"}
ScanQRData: dataQR : QRResponse(qrType=null, qrData=null)
Any suggestion what happened to qrType
and qrData
null after parse from Klaxon
?
Klaxon doesn't process
@field:SerializedName
annotation (where you have imported it from?). The correct way to customize mapping between your JSON documents and Kotlin objects in Klaxon is@Json
annotation: