To deserialize a JSON array that contains different types, I implemented a custom deserializer and a visitor to create a struct from the array. The array has always the same length and the same types.
Example: [2342394, "234.3", "243.2", 949] should be deserialized to
It seems my custom deserializer is confusing Serde, which somehow expects an array even in other places, when it's not necessary. A minimal example showing the problem is here:
In your sample JSON the last key is nested underneath result, thus it is part of the HashMap and the integer value cannot be deserialized as a Vec<Candle>. You need to move a closing bracket } in front of last.
Is there a reason why you are not using this definition of Candle?
Thanks to #[serde(flatten)], all the keys that are different from "last" end up in the HashMap, and the struct is deserialized automatically from the array as you both mentioned.