I’ve been playing with the <toolbox data class gen...
# http4k
d
I’ve been playing with the toolbox data class generator. What is the logic behind some of the odd names (eg Periods770648668 when there is no name clash), and generating more than one version of the same data class (I have 10 x Photos910613968 from a single .json file)?
d
The numbers are generated when there is a list of objects, which have different keysets when converted to JSON. The idea was to generate one unique object per keyset, so if you have polymorphic types you can just identify and rename them accordingly.
If all objects in a list are the same, only one will be generated.
We just always generate the number from the list regardless of how many items there are.
d
Yeah, it kind of snowballs though. I’ve ended up with 167 versions of
Copy code
data class AuthorAttributionsNNNNNNNN(
    val displayName: String?,
    val uri: String?,
    val photoUri: String?
)
with the same fields, which has led to 167 versions of
Copy code
data class Photos250036595(
    val name: String?,
    val widthPx: Number?,
    val heightPx: Number?,
    val authorAttributions: List<AuthorAttributions603326867>?
)
each with the same Photos250… suffix but a different specific List<AuthorAttributionsNNNN>
I feel like an episode on generating data classes coming on
d
Have you tried having smaller JSON? 😉
👯‍♂️ 1