I have this JSON to deserialize:
"data": {
"type": 18,
"msg": "firstName,lastName,15"
"timestamp": 1551770400000
}
I want to get this data in my model:
class DataDto(
type: String,
timestamp: Long,
msg: DataMsgDto?
) {
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JsonPropertyOrder("firstName", "lastName", "age")
class DataMsgDto(
firstName: String,
lastName: String,
age: Long
)
}
I use this code to get data:
DataBuffer payload //this is what I get from server
val jsonNode = objectMapper.readTree(payload.toString(StandardCharsets.UTF_8))
objectMapper.treeToValue(jsonNode, DataDto::class.java)
But this does not work because in msg I don't have fields. So, how can I do this?