Let's say I have JSON data like the following:
{
"type": "A",
"value": [ 1, 2, 3, 4, 5 ]
}
{
"type": "B",
"value": [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8 ] ]
}
type determines the type of value, which in the first example is Vec<u32> and in the second is Vec<Vec<u32>>.
If I represent the above data as follows:
enum DataValue {
TypeA(Vec<u32>),
TypeB(Vec<Vec<u32>>)
}
struct Data {
data_type: String,
value: DataValue
}
How do I implement serde deserialization to properly decode these values?