fdeantoni / prost-wkt

Prost Well-Known-Types serialization and deserialization.
Apache License 2.0
76 stars 35 forks source link

Downcasting Any to serde_json::Value #34

Closed dvtkrlbs closed 1 year ago

dvtkrlbs commented 1 year ago

I thought I would be able to downcast an Any type to serde_json::Value.

    let unpacked = content.try_unpack().unwrap();
    let value= unpacked.downcast_ref::<serde_json::Value>().unwrap();

    let title = value["title"].as_str().unwrap_or_else(|| "").to_string();
    let description = value["description"].as_str().unwrap_or_else(|| "").to_string();

    (title, description)

this is what i tried. Am I missing something or is this not possible.

dvtkrlbs commented 1 year ago

oh ok i got it now there is no field info on an any value