I have a JSON object (that I can't change) that passes some data like so:
{
"title": "foo",
"actions": "[
{
\"label\": \"Hello\"
}
]"
}
I'd like to deserialize the whole class with Moshi like so:
data class(
val title: String,
val actions: List<Action>
)
data class Action(
val label: String
)
However, because the actions field is wrapped with quotes, Moshi has an issue trying to deserialize a string where it expects an array. Is there any way, such as through an adapter or something, to have it properly deserialize the actions string as if it were a json object?
I ended up solving it with this system:
Then just annotate your property with
@JsonString