diff --git a/src/formats/serde.rs b/src/formats/serde.rs index 23be10a..2c5473d 100644 --- a/src/formats/serde.rs +++ b/src/formats/serde.rs @@ -3,6 +3,8 @@ use std::collections::HashMap; use zvariant::OwnedValue; //use std::hash::BuildHasher; use serde::ser::SerializeMap; +use serde_json::{Map,Value}; +use zvariant::SerializeValue; pub fn serialize_actions(actions: &[String], serializer: S) -> Result where @@ -27,19 +29,12 @@ pub fn serialize_hints( where S: Serializer, { - let mut hint_map = serde_json::Map::new(); - - for hint in hints { - let (hint_name, hint_val) = hint; - let mut h = serde_json::Map::new(); - let sig = hint_val.value_signature(); - let val = hint_val.try_clone(); - h.insert(sig.to_string(), serde_json::Value::String(val)); - - hint_map.insert(hint_name.clone(), serde_json::Value::Object(h.clone())); + // You can customize the serialization logic here + let mut state = serializer.serialize_map(Some(hints.len()))?; + for (key, value) in hints { + state.serialize_entry(key, value)?; } - - hint_map.serialize(serializer) + state.end() } /*