Aminu Babayo Shehu
01/30/2023, 1:05 PM{\"customerId\":\"123\",\"id\":\"registration\",\"value\":0,\"balance\":0,\"expirationDate\":1675122800125}
Please how to convert the above string to this Promotion object
sealed class Promotion(customerId: String, id: String, value: BigDecimal, balance: BigDecimal, expirationDate: Timestamp)
Sam
01/30/2023, 1:09 PMAminu Babayo Shehu
01/30/2023, 1:10 PMSam
01/30/2023, 1:12 PMAminu Babayo Shehu
01/30/2023, 1:12 PMval promotions = jacksonObjectMapper().readValue(promotion, Promotion::class.java)
Sam
01/30/2023, 1:17 PMdata
class instead of a sealed
class, though.Aminu Babayo Shehu
01/30/2023, 1:21 PM@Serializable
right?Sam
01/30/2023, 1:24 PMAminu Babayo Shehu
01/30/2023, 1:24 PM{{\"customerId\":\"123\",\"id\":\"registration\",\"value\":0,\"balance\":0,\"expirationDate\":1675086187278}, {\"customerId\":\"124\",\"id\":\"registration\",\"value\":0,\"balance\":0,\"expirationDate\":1675086187278}}
Sam
01/30/2023, 2:13 PM[]
, not braces {}
. If you had a valid JSON list, you could do jacksonObjectMapper().readValue<List<Promotion>>(promotions)
. If your list really does have braces instead of square brackets, it’s not valid JSON and you would need to fix it before passing it to a JSON deserializer.Aminu Babayo Shehu
01/30/2023, 2:17 PM