From b867e3230abb6cec561de02ecbdbe1bb7019497c Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 12 Jul 2019 03:56:09 -0700 Subject: [PATCH] Remove serde dependency. --- Cargo.toml | 4 ---- src/lib.rs | 31 +++++++++---------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c20ed84..d0646250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,3 @@ base64 = "0.10.1" ring = "0.14.6" serde_json = "1.0.39" untrusted = "0.6.2" - -[dependencies.serde] -version = "1.0.90" -features = ["derive"] diff --git a/src/lib.rs b/src/lib.rs index 76ebad09..6108ca68 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -228,8 +228,7 @@ mod test { use std::collections::HashMap; use base64::{decode_config, STANDARD_NO_PAD}; - use serde::Serialize; - use serde_json::{from_str, to_string, to_value, Value}; + use serde_json::{from_str, json, to_string, to_value, Value}; use super::{ canonical_json, hash_and_sign_event, sign_json, verify_event, verify_json, Ed25519KeyPair, @@ -373,18 +372,6 @@ mod test { #[test] fn sign_minimal_json() { - #[derive(Serialize)] - struct Alpha { - one: u8, - two: String, - } - - #[derive(Serialize)] - struct ReverseAlpha { - two: String, - one: u8, - } - let key_pair = Ed25519KeyPair::new( decode_config(&PUBLIC_KEY, STANDARD_NO_PAD) .unwrap() @@ -396,15 +383,15 @@ mod test { ) .unwrap(); - let alpha = Alpha { - one: 1, - two: "Two".to_string(), - }; + let alpha = json!({ + "one": 1, + "two": "Two", + }); - let reverse_alpha = ReverseAlpha { - two: "Two".to_string(), - one: 1, - }; + let reverse_alpha = json!({ + "two": "Two", + "one": 1, + }); let mut alpha_value = to_value(alpha).expect("alpha should serialize"); sign_json("domain", &key_pair, &mut alpha_value).unwrap();