#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "json")]
use serde_json::{from_str, to_string, Result as SerdeResult};
#[cfg(feature = "json")]
pub trait ToFromJson<'de>
where
Self: Sized + Serialize + Deserialize<'de>,
{
fn from_json(json: &'de str) -> SerdeResult<Self> {
from_str(json)
}
fn to_json(&self) -> SerdeResult<String> {
to_string(self)
}
}