RPC deserialization only when the params are empty
@@ -534,11 +534,10 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for EditCommand<T>
let helper = InnerId::deserialize(&v).map_err(de::Error::custom)?;
let InnerId { view_id } = helper;
- if T::deserialize(v.clone()).is_err() {
// if params are empty, remove them
let remove_params = match v.get("params") {
- Some(&Value::Object(ref obj)) => obj.is_empty(),
- Some(&Value::Array(ref arr)) => arr.is_empty(),
+ Some(&Value::Object(ref obj)) => obj.is_empty() && T::deserialize(v.clone()).is_err(),
+ Some(&Value::Array(ref arr)) => arr.is_empty() && T::deserialize(v.clone()).is_err(),
Some(_) => return Err(de::Error::custom("'params' field, if present, must be object or array.")),
None => false,
};
@@ -546,7 +545,6 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for EditCommand<T>
if remove_params {
v.as_object_mut().map(|v| v.remove("params"));
}
- }
let cmd = T::deserialize(v).map_err(de::Error::custom)?;
Ok(EditCommand { view_id, cmd })
