JSON I want to parse in rust using Serde:
[999,{"a":[[1,2,3], [12,3]], "b":[[1,2,3], [12,3]]}, "some_string"]
I was trying to use
#[derive(Deserialize)]
pub struct SnapshotMessage {
id: i32,
snapshot: Snapshot,
channel: String,
}
#[derive(Deserialize)]
struct Snapshot {
a: Vec<Level>,
b: Vec<Level>
}
This does not work because there is no mapping for id. I cant see anyway to deal with a custom array at the root level if it was just an array of identical objects I could simply do Vec but this is not a uniform root list.
One of my ideas is to use a custom deserializer but is there a way to only write part of a deserizlizer so that I can use derived for nested objects?
What is the best way to handle non uniform root arrays?