-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value isn't encodable/decodable #43
Comments
It's a bit tricky to implement. I'll try to implement for serde. |
Would this make it possible to handle something similar to this example from //#![feature(custom_derive, plugin)]
//#![plugin(serde_macros)]
extern crate serde_json;
use serde_json::Value;
fn main() {
let data: Value = serde_json::from_str("{\"foo\": 13, \"bar\": \"baz\"}").unwrap();
println!("data: {:?}", data);
// data: {"bar":"baz","foo":13}
println!("object? {}", data.is_object());
// object? true
let obj = data.as_object().unwrap();
let foo = obj.get("foo").unwrap();
println!("array? {:?}", foo.as_array());
// array? None
println!("u64? {:?}", foo.as_u64());
// u64? Some(13u64)
for (key, value) in obj.iter() {
println!("{}: {}", key, match *value {
Value::U64(v) => format!("{} (u64)", v),
Value::String(ref v) => format!("{} (string)", v),
_ => format!("other")
});
}
// bar: baz (string)
// foo: 13 (u64)
} E.g. deserializing some generic MessagePack data, or have I misunderstood this issue? |
You can deserialize the bytearray into a This issue is about implementing |
It would be fantastic if we could get this. |
Please check this as there is the first look on serialization support for Value. If everything is ok, I'm going to implement deserization too. Unfortunately, it's required to wrap |
@3Hren Have you experimented with implementing |
Now after I've moved https://github.com/3Hren/msgpack-rust/blob/master/rmpv/src/ext.rs |
I'm (slowly) working on #40, and I'm running into a problem with representing heterogenous lists (for arguments). I've resorting to using
Vec<Value>
as a struct field. However, sinceValue
isn't encodable, it's difficult to serialize it as part of a larger struct.The text was updated successfully, but these errors were encountered: