From 2d42401b52fd65e2c1afa28ef731428325806330 Mon Sep 17 00:00:00 2001 From: candifloss Date: Sun, 20 Oct 2024 23:13:07 +0530 Subject: [PATCH] commit --- src/formats/serde.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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() } /*