Skip to content

Instantly share code, notes, and snippets.

@kybishop
Last active January 19, 2017 10:29
Show Gist options
  • Save kybishop/ecf48136e0a189ebd8dbac4b93303d33 to your computer and use it in GitHub Desktop.
Save kybishop/ecf48136e0a189ebd8dbac4b93303d33 to your computer and use it in GitHub Desktop.
extern crate serde_json;
fn main() {
decode_json();
}
fn decode_json() -> Result<(), ()> {
// This works: let json: serde_json::Value = serde_json::from_str("[{}]").map_err(|error| {
// The below does not
let json = serde_json::from_str("[{}]").map_err(|error| {
println!("Error while decoding JSON: {:?}", error);
})?;
println!("JSON from string: {:?}", json);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment