#Deserializing an optional JSON Value that can only take 2 values
1 messages · Page 1 of 1 (latest)
1 messages · Page 1 of 1 (latest)
How would I use serde to deserialize json objects of the following nature.
[
{
"id": 42,
"value": "foo",
"auxValue": "bar"
},
{
"id": 43,
"value": "faz",
"auxValue": 23e+1626
},
{
"id": 44,
"value": "quox",
},
]
auxValue can be a string, a number, or not present at all
i was thinking about some Option and Enum combination
Yeah, that's probably the simplest way, an Option holding the enum. The enum would be #[serde(untagged)]