home ~ projects ~ socials

Get A Generic JSON5 Object From A String In Rust

This is how I'm pulling JSON5 data into objects without an explict type in Rust:

```cargo
[dependencies]
serde_json = "1.0.132"
serde_json5 = "0.1.0"
```

use serde_json::Value;
use serde_json5;

fn main() {
  let text = r#"{ "alfa": "foxtrot" }"#;
  let data = serde_json5::from_str::<Value>(&text);
  dbg!(data.unwrap());

}
Output:
[/Users/alan/.cargo/target/55/19854259915251/_active_nvim_run:13:3] data.unwrap() = Object {
    "alfa": String("foxtrot"),
}
-- end of line --

References