Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Parse A JSON String With Serde In Rust

Code

```cargo
[dependencies]
 serde_json = "1.0.111"
```

use serde_json::Value;

fn main() {
  let text = r#"{ "color": "red" }"#;
  match serde_json::from_str::<Value>(text) {
    Ok(data) => { dbg!(data); () } ,
    Err(e) => { dbg!(e); () }
  };
}

Results

[/Users/alan/.cargo/target/55/19854259915251/_active_nvim_run:11:19] data = Object {
    "color": String("red"),
}