-
Notifications
You must be signed in to change notification settings - Fork 146
Closed
Description
I'm not 100% sure this is a bug, but looking at the code, it seems it is not the intention. Let's have a code:
extern crate rmp_serde;
extern crate rmpv;
#[macro_use]
extern crate serde_derive;
use rmp_serde::to_vec;
use rmpv::decode::read_value;
#[derive(Serialize)]
struct Test {
field: usize,
another: String,
}
fn main() {
let data = Test {
field: 42,
another: "Hello".to_owned(),
};
let vec = to_vec(&data).unwrap();
let val = read_value(&mut vec.as_slice()).unwrap();
println!("{}", val);
}
And it prints: [42, "Hello"]
. That isn't entirely incorrect and could be one of the possible ways to serialize it and deserializing it again works. However, when I look into the code, I'd expect something like [("field": 42), ("another": "Hello")]
(eg. using a map, with the field names). It would also be compatible with what serde-json
does.
Is this the intention and I read the code differently, or is this a bug somewhere? Is the other way possible somehow, maybe by configuring the serializer somehow before using it?
Metadata
Metadata
Assignees
Labels
No labels