An API I hit has poorly structured JSON. Someone decided that it was a great idea to send back a list that looks like this
features: [
"First one",
"second one",
{
"feature": "third one",
"hasAdditionalImpact": true
},
"forth one"
]
I've figured out a way to get this data into a struct but that was effectively:
struct MyStruct {
SensibleData: String,
SensibleTruthy: bool,
features: serde_json::Value,
}
This doesn't help me normalize and verify the data.
Is there a good way to turn that first object into something like
features: [
{
"feature": "First one",
"hasAdditionalImpact": false
},
{
"feature": "second one",
"hasAdditonalImpact": false
},
{
"feature": "third one",
"hasAdditionalImpact": true
},
{
"feature": "forth one",
"hasAdditionalImpact": false
}
]
I saw type_name might be usable for checking the type and doing post-processing after it's be parsed by serde_json
, but I also saw that type_name
is for diagnostic purposes so I'd rather not use that for this purpose.