I'm trying to do something for a JSON parser. I ha...
# announcements
s
I'm trying to do something for a JSON parser. I have a bunch of properties named "%type%Sold" and "%type%Base" which contain a CountryCode and an amount. There's like 5 different times these repeat. I'm trying to figure out the best way to structure the model for this. I was trying to use sealed classes with data classes, but that seems rather unwieldy. Here's what I've got so far:
Copy code
sealed class Amount(
  val currency: Currency,
  val value: Long,
  val type: String
) {
  data class Sold(override val currency: Currency, override val amount: Long): Amount(currency, amount, "Sold)
On top of that, there are a few prefixes of "total", "dayOf", etc that have a handful of things in the JSON, of which Amount is just one