use anyhow::Result;
use serde_json::Value;
pub mod macros;
pub mod rust;
pub trait GenCodeByValue {
fn gen(&self) -> String;
}
pub fn gen_by_str(name: &str, s: &str) -> Result<String> {
let v: Value = serde_json::from_str(&s)?;
let obj = rust::parse_value(name, v);
let mut content = obj.gen();
content.insert_str(0, "use serde::{Deserialize, Serialize};\n\n");
Ok(content)
}