3 ms·
Rust: let foo: serde_json::Value = serde_json::from_str(arbitraryJsonString)?; There, just as powerful [1]. But you know what's even more powerful? After
by adwn 5y ago
Rust:
let foo: serde_json::Value = serde_json::from_str(arbitraryJsonString)?;
There, just as powerful [1]. But you know what's even more powerful? After you've done your dynamic checks, you can do this on the entire JSON tree, or on a subtree:
let bar: MyStaticType = serde_json::from_value(foo)?;
and you get a fully parsed instance of a static type, with all the guarantees and performance benefits that entails.
[1] Value represents a JSON tree: https://docs.serde.rs/serde_json/enum.Value.html https://docs.serde.rs/serde_json/enum.Value.html