derive Serialize Deserialize macros
Add derive macro to for auto serialization and deserialization implementation generation.
@xlc I want to try to tackle this issue.
Currently, I am using code here to get a certain value/object out from JsonValue. But this is kind of tedious. Will be nice if we can do something like what serde does.
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
let serialized = serde_json::to_string(&point).unwrap();
println!("serialized = {}", serialized);
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
println!("deserialized = {:?}", deserialized);
// So in lite-json
let deserialized2: Point = lite_json::parse_json(&serialized).unwrap().deserialize().unwrap();
}
I am still not sure about the implementation yet. How hard would it be to do something like this in no_std env?
@jimmychu0807 I have started it at #13 and you are welcome to finish it. You can PR into derive branch.
Current status is it compiles, but I never ran it once so likely missing a lot of details.
The code is heavily inspired by parity-scale-codec.
Thanks. Let me take a look
I would love to see this 🤞