Crates.io | serde_var_export |
lib.rs | serde_var_export |
version | 0.1.0 |
source | src |
created_at | 2020-01-22 08:31:11.520742 |
updated_at | 2020-01-28 08:49:01.908747 |
description | PHP function var_export() support for Serde. |
homepage | |
repository | https://github.com/jmjoy/serde_var_export |
max_upload_size | |
id | 200980 |
size | 39,133 |
PHP function var_export()
support for Serde.
With cargo add installed run:
$ cargo add -s serde_var_export
use serde_derive::Serialize;
#[derive(Serialize)]
struct Foo {
names: Vec<String>,
nums: Vec<i32>,
}
fn main() {
let foo = Foo {
names: vec!["hello".to_owned(), "world".to_owned()],
nums: vec![1, 2, 3],
};
let s = serde_var_export::to_string(&foo).unwrap();
println!("{}", s);
}
print result:
array(
'names' =>
array(
0 => 'hello',
1 => 'world',
),
'nums' =>
array(
0 => 1,
1 => 2,
2 => 3,
),
)
Now only support serialization, deserialization will support in future.
The Unlicense.