diff --git a/src/de.rs b/src/de.rs index 97dc115..0e969b6 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1,4 +1,4 @@ -use serde::{forward_to_deserialize_any, de}; +use serde::{forward_to_deserialize_any, de::{self, VariantAccess}}; use std::collections::BTreeMap; use std::error::Error; use std::fmt; @@ -289,6 +289,16 @@ impl<'de> de::Visitor<'de> for ValueVisitor { fn visit_byte_buf(self, v: Vec) -> Result { Ok(Value::Bytes(v)) } + + fn visit_enum>(self, data: A) -> Result { + let mut map = BTreeMap::new(); + let (key, value) = data.variant()?; + let value = value + .newtype_variant() + .unwrap_or(Value::Unit); + map.insert(key, value); + Ok(Value::Map(map)) + } } impl<'de> de::Deserialize<'de> for Value {