Skip to content

Commit

Permalink
Update src/proxy/compute/data_collection/components/convert.rs
Browse files Browse the repository at this point in the history
Co-authored-by: KokaKiwi <julianne@edgee.cloud>
  • Loading branch information
SachaMorard and KokaKiwi committed Nov 5, 2024
1 parent e0a9cb1 commit 27611f7
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/proxy/compute/data_collection/components/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,22 @@ impl From<payload::Session> for provider::Session {
}

fn convert_dict(dict: Option<HashMap<String, serde_json::Value>>) -> Vec<(String, String)> {
let mut vec: Vec<(String, String)> = vec![];
if dict.is_none() {
return vec![];
}
for (k, v) in dict.unwrap().iter() {
if v.is_object() || v.is_array() {
continue;
}
let s = v.as_str();
if let Some(s) = s {
vec.push((k.clone(), s.to_string()));
} else {
vec.push((k.clone(), v.to_string()));
}
}
vec
use serde_json::Value;

let Some(dict) = dict else {
return Vec::new();
};

dict.into_iter()
.filter(|(_, value)| !(value.is_array() || value.is_object()))
.map(|(k, v)| {
let value = if let Value::String(s) = v {
s
} else {
v.to_string()
};

(k, value)
})
.collect()
}

0 comments on commit 27611f7

Please sign in to comment.