reqrio_json/
ext.rs

1use serde::{Deserialize, Serialize};
2use crate::{JsonResult, JsonValue};
3
4pub trait JsonExt
5where
6    Self: Serialize + for<'a> Deserialize<'a>,
7{
8    fn new() -> Self;
9}
10
11impl JsonValue {
12    pub fn to_struct<T: JsonExt>(self) -> JsonResult<T> {
13        let mut self_struct = crate::from_struct(&T::new())?;
14        self_struct.update_by(self)?;
15        self_struct.as_struct()
16    }
17}