Expand description

This module provides a procedural macro to derive JSONValue for custom structs.

Examples

extern crate json_in_type;
#[macro_use] extern crate json_in_type_derive;
use json_in_type::JSONValue;

#[derive(JSONValue)]
struct MyObject {
    void: (),
    list: Vec<u8>,
    hello: String,
}

let obj = MyObject {
    void: (),
    list: vec![1, 2, 3],
    hello: String::from("world"),
};
assert_eq!(
    r#"{"void":null,"list":[1,2,3],"hello":"world"}"#,
    obj.to_json_string()
);

Derive Macros

Derive JSONValue for a structure