我在想是否可以在Rust中解码一个具有与Rust关键字相同的属性名称的JSON对象。我正在使用rustc-serialize
创建,并且我的结构定义如下:
#[derive(RustcDecodable)]
struct MyObj {
type: String
}
编译器发生错误,因为 type
是一个关键字。error: expected identifier, found keyword `type`
src/mysrc.rs:23 type: String,
^~~~
impl Decodable
是唯一的方法? - rking788Json::from_str
然后深入其结果值。 - Shepmaster