I have a set of JSON files with keys obfuscated, and could obtain a mapping to deobfuscate at runtime. Since serde's
derive(deserialize) supports only compile-time
rename = "...", the
Deserialize trait is stateless, and
DeserializeSeed is not quite composable, I decide to write a generic deserializer wrapper to match and deobfuscate mapping keys at runtime.
This is harder than I initially thought. After spending hours with ownership, lifetime,
MapAccess, etc, I still could not achieve my goal. Currently, I took a simpler approach, by modifying upon
serde_transcode (which implement Serialize and Deserialize on the Transcode struct in a smart way), to deobfuscate the keys first, produce an new JSON string, then deserialize into structs.
I wonder, is there a minimal example of wrapping a
Deserializer (and also
MapAccess). I saw
serde_with did something similar, but not dig into the details yet.