Hey friends! Looking for some help on keeping a subset of JSON in string-form
I have JSON like
{
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{
"value": "New",
"onclick": "CreateDoc()"
},
{
"value": "Open",
"onclick": "OpenDoc()"
},
{
"value": "Save",
"onclick": "SaveDoc()"
}
]
}
}
I'd like to represent it with a
data class Menu(val id: String, val value: String, val popup: String)
where the
popup
subtree is stored as a String of valid JSON, instead of having to deserialize the whole nested
popup
structure.
Happy to write a custom serializer for this because it doesn't happen too frequently in our codebase.