Giter Club home page Giter Club logo

serde's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serde's Issues

cannot parse into a sequence before knowing it's a sequence

I have structure A with a sequence field (vector) and want to parse some xml into it.

struct A {
    some_field: Vec<String>,
}

The following xml is the canonical way of expressing such a structure (see xsd maxOccurs)

<A>
    <some_field>Hi</some_field>
    <some_field>42</some_field>
    <some_field>This is a test!</some_field>
</A>

During parsing I don't know yet that a sequence is expected, so in the visit_value function of the MapVisitor I'd attempt to decode the first value ("55") to a sequence. This will fail out of the obvious reason that the VecVisitor expects the visit_seq function. I cannot implement all visit_* functions and return a single value vector, as this idea would fail at the second element, which can't be added to that vector (and would fail horribly for fixed-length sequences like tuples).

Would this be a situation where Deserializer should be extended (with a visit_seq function)? Or will something like that yield some problems that libserialize has?

struct field alias is a rename, not an alias

parsing

{
    "a1": "some text",
    "a2": 42
}

to the following structure

    #[derive(PartialEq, Debug, Serialize, Deserialize)]
    struct A {
        a1: String,
        #[serde(alias="a3")]
        a2: i32,
    }

will fail, because serde completely replaces all instances of a2 with a3. The keyword "alias" sounds to me more like both should be accepted.

Maybe this feature should simply be renamed to "rename"?

Integer overflow when parsing JSON

Code

#![feature(plugin)]
#![plugin(afl_coverage_plugin)]

extern crate afl_coverage;

extern crate serde;

use std::io::{self, Read, Cursor};

use serde::json::{self, Value};


fn main() {
    let mut input = String::new();
    let result = io::stdin().read_to_string(&mut input);
    if result.is_ok() {
        let _: Result<Value, _> = json::from_str(&input);
    }
}

Input

777777777777777777777777777

Crash

root@vultr:~/afl-staging-area2# cargo run < outputs/crashes/id\:000000\,sig\:04\,src\:000000\,op\:havoc\,rep\:16
     Running `target/debug/afl-staging-area2`
thread '<main>' panicked at 'arithmetic operation overflowed', /root/serde/src/json/de.rs:201
An unknown error occurred

To learn more, run the command again with --verbose.

This bug was found using https://github.com/kmcallister/afl.rs ๐Ÿ‘

Stack overflow when parsing lots of open square brackets

Code

#![feature(plugin)]
#![plugin(afl_coverage_plugin)]

extern crate afl_coverage;

extern crate serde;

use std::io::{self, Read, Cursor};

use serde::json::{self, Value};


fn main() {
    let mut input = String::new();
    let result = io::stdin().read_to_string(&mut input);
    if result.is_ok() {
        if let Ok(j) = json::from_str::<json::Value>(&input) {
            let _ = json::to_string(&j);
        }
    }
}

Input

{"":"","":"๐Ÿ˜‚","":"๐Ÿ˜‚","":[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0

Crash

root@vultr:~/afl-staging-area2# cargo run < newtest
     Running `target/debug/afl-staging-area2`

thread '<main>' has overflowed its stack
An unknown error occurred

To learn more, run the command again with --verbose.

This bug was found using https://github.com/kmcallister/afl.rs ๐Ÿ‘

Optional fields return MissingFieldError/SyntaxError

I'm working on something for hematite / hematite_server and found that Option<T> is not working as it should. There's a couple more places where we use it so this is bad news for us.

Here's my test case, probaby most of struct fields are not necessary, I'll try minimizing this further.

#![feature(custom_derive)]
#![feature(plugin)]
#![plugin(serde_macros)]
extern crate serde;

use serde::json;

/// Response sent to clients as JSON.
#[derive(Debug)]
#[derive_serialize]
#[derive_deserialize]
pub struct Response {
    pub description: String,
    pub favicon: Option<String>,
    pub players: Players,
}

#[derive(Debug)]
#[derive_serialize]
#[derive_deserialize]
pub struct Players {
    pub max: i32,
    pub online: i32,
    pub sample: Option<Vec<Sample>>,
}

#[derive(Debug)]
#[derive_serialize]
#[derive_deserialize]
pub struct Sample {
    pub name: String,
    pub id: String,
}

fn main() {
    let blob = r#"{"description":"A Minecraft Server","players":{"max":20,"online":0}}"#;
    let resp: Response = json::from_str(blob).unwrap();
    println!("{:?}", resp);
}

This panics with the following messages:

  • thread '<main>' panicked at 'called Result::unwrap()on anErr value: SyntaxError("expected value", 0, 0)' We get this if we comment out the players field in Players struct.
  • thread '<main>' panicked at 'called Result::unwrap()on anErr value: MissingFieldError("sample")'

allow deserialization to work with missing attributes

When parsing JSON I'd like to only parse parts of the payload, e.g.

given JSON like { 'x': 32, 'y': 12 } I'd expect serde to deserialize it using the following struct:

#[derive(Serialize, Deserialize)]
#[allow(non_snake_case)]
struct Point {
    y: f32,
}

However, this fails with an UnknownField("x") error.

This is important if you are only interested in parts of the payload, or if working with dynamic payload.

Should I use Serde for `google-apis-rs` ?

Hi,

Sorry for using the ticket system for something that clearly is a question ... but here I am.
It seems that serde could be the answer to my problem, and I wonder if you have any objections against my plan to switch all json encoding tasks to serde.

One objection could be something like: "don't do it - serde will be unsupported soon and is nothing more than a (failed) experiment !!" ?

I hope not, but wanted to be sure :) !

Thank you,
Sebastian

Multiple external field names

I'm using serde to interact with Amazon's EC2 API. The API uses url-encoded parameters on input and returns XML. I am using serde for both serialisation and deserialisation. However, the field names expected by EC2 on input are different from the field names returned in the XML.

I can see several ways of solving this:
a) Extend serde to allow renaming fileds differently on serialisation and on deserialisation, possibly via rename_ser and rename_de annotations.
b) Extend serde to allow Serialiser specific field encodings.
c) Create parallel data structures for input and output data.

Option c) obviously does not require any change in serde, but I'm reluctant to go this route, as it involves significant extra code (there are approx 650 structs used in the EC2 api), particularly in order to hide the duplication in the exposed api, and compile times are already awful (>5mins).

Option a) seems relatively simple to implement, but adds some complexity to serde. Cognitive complexity can be limited by keeping the rename annotation for the case where the field names are identical for both serialisation and deserialisation.

Option b) seems the most flexible, but would probably add more complexity to serde, espescially for implementors of Serializer, and would likely incur extra runtime overhead.

Would either of a) or b) be considered for serde?

Issue compiling with dependency rand

Hi,

When I tried to install serde (just put serde = "0.4.0" in my cargo.toml) I received the following errors when cargo decided to get rand:

Command: ~ cargo build --verbose

Error report:

   Compiling rustc-serialize v0.3.14
     Running `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/lib.rs --crate-name rustc_serialize --crate-type lib -g -C metadata=9ef26f158d5284e0 -C extra-filename=-9ef26f158d5284e0 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps -Awarnings`
   Compiling rand v0.3.8
     Running `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs --crate-name rand --crate-type lib -g -C metadata=b924d9fc5b3eb5b8 -C extra-filename=-b924d9fc5b3eb5b8 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps --extern libc=/Users/logan/work/rust-project/target/debug/deps/liblibc-2eda841eb12a3090.rlib -Awarnings`
       Fresh libc v0.1.8
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs:237:5: 237:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs:237 use std::num::Wrapping as w;
                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/chacha.rs:13:5: 13:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/chacha.rs:13 use std::num::Wrapping as w;
                                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/isaac.rs:17:5: 17:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/isaac.rs:17 use std::num::Wrapping as w;
                                                                                                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/distributions/range.rs:15:5: 15:28 error: unresolved import `std::num::Wrapping`. There is no `Wrapping` in `std::num`
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/distributions/range.rs:15 use std::num::Wrapping as w;
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors
Build failed, waiting for other jobs to finish...
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:435:5: 435:30 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:480:13: 480:46 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:483:9: 483:37 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:489:9: 489:41 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:492:5: 492:30 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:508:9: 508:33 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:513:9: 513:39 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:601:9: 601:43 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:605:62: 605:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:605:62: 605:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:606:58: 606:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:606:58: 606:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:607:58: 607:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:607:58: 607:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:608:58: 608:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:608:58: 608:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:609:56: 609:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:609:56: 609:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:611:62: 611:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:611:62: 611:97 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:612:58: 612:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:612:58: 612:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:613:58: 613:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:613:58: 613:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:614:58: 614:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:614:58: 614:93 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:615:56: 615:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:615:56: 615:91 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:620:13: 620:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:622:13: 622:48 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:533:13: 533:53 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:628:9: 629:6 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:536:13: 536:49 note: expansion site
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:530:1: 540:2 note: in expansion of emit_enquoted_if_mapkey!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:628:9: 629:6 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:663:17: 663:51 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:666:17: 666:60 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:668:17: 668:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:670:17: 670:62 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:673:17: 673:61 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:675:17: 675:60 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:680:17: 680:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:683:17: 683:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:685:17: 685:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:687:17: 687:50 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:698:13: 698:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:700:17: 700:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:736:13: 736:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:738:13: 738:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:745:17: 745:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:748:13: 748:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:758:13: 758:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:761:13: 761:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:766:13: 766:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:768:13: 768:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:821:13: 821:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:823:13: 823:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:830:17: 830:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:833:13: 833:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:843:13: 843:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:846:13: 846:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:857:13: 857:47 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:859:13: 859:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:866:17: 866:49 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:869:13: 869:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:879:13: 879:44 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:882:13: 882:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:896:13: 896:45 note: expansion site
<std macros>:6:1: 6:41 error: the trait `core::error::FromError<core::fmt::Error>` is not implemented for the type `json::EncoderError` [E0277]
<std macros>:6 $ crate:: error:: FromError:: from_error ( err ) ) } } )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:57 note: in expansion of try!
/Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.14/src/json.rs:898:13: 898:44 note: expansion site
error: aborting due to 66 previous errors
Could not compile `rand`.

Caused by:
  Process didn't exit successfully: `rustc /Users/logan/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.8/src/lib.rs --crate-name rand --crate-type lib -g -C metadata=b924d9fc5b3eb5b8 -C extra-filename=-b924d9fc5b3eb5b8 --out-dir /Users/logan/work/rust-project/target/debug/deps --emit=dep-info,link -L dependency=/Users/logan/work/rust-project/target/debug/deps -L dependency=/Users/logan/work/rust-project/target/debug/deps --extern libc=/Users/logan/work/rust-project/target/debug/deps/liblibc-2eda841eb12a3090.rlib -Awarnings` (exit code: 101)

[Design] type-directed serialisation

Hi.

At the moment, the usage of the de::Deserializer trait seems to work under the assumption that the input syntactically discriminates between scalar, sequence-like and map-like values.

I had a go at using serde to implement serialization for lisp-like s-expressions, which only have scalars and lists in the base syntax, and so because most of the visitors call into the de::Deserializer#visit method, I found that I was having to add explicit tags for whether a value was an integer, float, list, or a map.

Given that we'll know the type of the value we're attempting to de-serialize at compile time, can you think of any particular reason why it might not be feasible to remove the #visit method, and just rely on types to direct what kind of syntactic construct we should expect?

Put another way, if we have a grammar with multiple potential start-rules, I'd like to be able to use the expected type to decide which start-rule to use.

ICE while generating deserialization code for an empty structure

Code:

#[deriving_deserializable]
pub struct EmptyStruct;

gives:

task 'rustc' failed at 'explicit failure', src/lib.rs:374

stack backtrace:
   1:     0x7f5f0bdb2ed0 - rt::backtrace::imp::write::h53108151a1c919cdOLq
   2:     0x7f5f0bdb6070 - failure::on_fail::hce96b96ffc877504w7q
   3:     0x7f5f10393930 - unwind::begin_unwind_inner::hab46511b32d4adddZ2d
   4:     0x7f5f010f2060 - unwind::begin_unwind::h13816885806571095130
   5:     0x7f5f0112d300 - deserialize_struct_from_map::h0d2f3ac6892eda813Ua
   6:     0x7f5f01124d20 - deserialize_struct::h7f8c1462b2a2f856PDa
   7:     0x7f5f011247b0 - deserializable_substructure::h876b802736a25d5dxCa
   8:     0x7f5f011246c0 - expand_deriving_deserializable::closure.5785
   9:     0x7f5f0d6ed3d0 - ext::deriving::generic::MethodDef<'a>::call_substructure_method::h9fd3376ea9de9a7diI8
  10:     0x7f5f0d6ea4e0 - ext::deriving::generic::MethodDef<'a>::expand_static_struct_method_body::h0cb48135e3132db7wV8
  11:     0x7f5f0d6b5c90 - ext::deriving::generic::TraitDef<'a>::expand::h4085fd61be246f96Dw8
  12:     0x7f5f010f5870 - expand_deriving_deserializable::hc0b16f9cd2313bd9axa
  13:     0x7f5f0d701ef0 - ext::expand::expand_item::h430bd08f8d8911acN29
  14:     0x7f5f0d70a790 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h159780893c663cf3kPa
  15:     0x7f5f0d70a730 - fold::noop_fold_mod::closure.51810
  16:     0x7f5f0d6abee0 - iter::Iterator::collect::h3193262790309689773
  17:     0x7f5f0d709d00 - fold::Folder::fold_mod::h14759044108703861783
  18:     0x7f5f0d708030 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item_underscore::he7bcae9748216087GPa
  19:     0x7f5f0d707cf0 - fold::noop_fold_item::h2689482478486837807
  20:     0x7f5f0d701ef0 - ext::expand::expand_item::h430bd08f8d8911acN29
  21:     0x7f5f0d70a790 - ext::expand::MacroExpander<'a, 'b>.Folder::fold_item::h159780893c663cf3kPa
  22:     0x7f5f0d70a730 - fold::noop_fold_mod::closure.51810
  23:     0x7f5f0d6abee0 - iter::Iterator::collect::h3193262790309689773
  24:     0x7f5f0d709d00 - fold::Folder::fold_mod::h14759044108703861783
  25:     0x7f5f0d739870 - ext::expand::expand_crate::hf7f24e183a475ae6dSa
  26:     0x7f5f11292ea0 - driver::driver::phase_2_configure_and_expand::closure.138149
  27:     0x7f5f11088150 - driver::driver::phase_2_configure_and_expand::h86ce50a58acc97ad3PB
  28:     0x7f5f11254780 - driver::driver::compile_input::h8608525c5b471524uJB
  29:     0x7f5f112e84d0 - driver::run_compiler::h69b3fcd2a164d565UyF
  30:     0x7f5f112e83e0 - driver::main_args::closure.141489
  31:     0x7f5f112fafe0 - task::TaskBuilder<S>::try_future::closure.142658
  32:     0x7f5f112fade0 - task::TaskBuilder<S>::spawn_internal::closure.142635
  33:     0x7f5f106eb530 - task::spawn_opts::closure.8397
  34:     0x7f5f103e9660 - rust_try_inner
  35:     0x7f5f103e9650 - rust_try
  36:     0x7f5f103910f0 - unwind::try::hd6387be7e7aa758afRd
  37:     0x7f5f10390f50 - task::Task::run::hb83ab5c92810e88692c
  38:     0x7f5f106eb290 - task::spawn_opts::closure.8343
  39:     0x7f5f10392a60 - thread::thread_start::hd97e8e956809086bgod
  40:     0x7f5f0b150060 - start_thread
  41:     0x7f5f10062489 - __clone
  42:                0x0 - <unknown>


--- stderr
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace

`Box<_>` support for serde

I have a recursive structure which looks very much like this:

/// There is no detailed description.
/// 
/// This type is not used in any activity, and only used as *part* of another schema.
/// 
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ItemScope {
    /// The start date and time of the event (in ISO 8601 date format).    
    #[serde(alias="startDate")]
    pub start_date: String,
    /// The end date and time of the event (in ISO 8601 date format).    
    #[serde(alias="endDate")]
    pub end_date: String,
    /// The text that is the result of the app activity. For example, if a user leaves a review of a restaurant, this might be the text of the review.    
    pub text: String,
    /// A URL to the image that represents this result. For example, if a user writes a review of a restaurant and attaches a photo of their meal, you might use that photo as the result.image.    
    pub image: String,
    /// Review rating.    
    #[serde(alias="reviewRating")]
    pub review_rating: Option<Box<ItemScope>>,
}

As you can see, I have to use a Box to allow such a struct to exist. With rustc_serialize, I was able to encode and decode it, with serde I get errors like this:

the trait `serde::de::Deserialize` is not implemented for the type `Box<ItemScope>`

This is just happening for me in the plus1 API, so it's by no means a show-stopper.
Also I may note that with an older compiler version (and rustc_serialize) I was able to just use Box<ItemScope> without issues. Now, it really wants Option<Box<ItemScope>> - may be a bug.

Details on where this issue is coming from can be watched on youtube.

Meta

โœ— rustc --version --verbose
rustc 1.0.0-nightly (ea8b82e90 2015-03-17) (built 2015-03-18)
binary: rustc
commit-hash: ea8b82e90c450febb1f26a07862a1ec89c22addd
commit-date: 2015-03-17
build-date: 2015-03-18
host: x86_64-apple-darwin
release: 1.0.0-nightly
โžœ  rust-serde git:(master) glog
* 42bd905 (HEAD, mine/master, master) fix(macros): fully qualified usage of `Result`
* 5378d22 (origin/master, origin/HEAD) Switch to the new custom_deserialize syntax
* c8b2ad0 Update to rust HEAD
* e778c7e Update to rust HEAD
*   f0d0dd2 Merge pull request #41 from hugoduncan/feature/mark-field-attributes-used
|\
| * 3e63d34 Mark serde field attributes as used
|/

Implement Serialize for std::path::PathBuf

Serde should probably implement the Serialize trait for the new path module's PathBuf and Path types, since otherwise any struct using fields of these types will need a custom serialiser. The same for deserialisation.

more flexible JSON serialization

Serialization for machines

When structures are serialized to JSON to be transferred over the wire, there may be servers that expect null values to be omitted, possibly to save bandwidth. Right now, there is no way in serde to omit null values.

As a practical example, imagine someone trying to upload a video to youtube:

$ youtube3 --debug videos insert \
-r snippet \
title="Google APIs for Rust: Developer Diary #2 [Making CLIs]" \
description="TBD" \
tags="Google APIs, Google, rust-lang, Diary, OSS" \
category-id=22 \
..status privacy-status=private \
embeddable=true \
license=youtube \
-u resumable ~/Movies/youtube-originals/Google\ APIs\ for\ Rust\ -\ Using\ youtube3\ to\ upload\ a\ video.mov application/octet-stream

Which yields the following error:

Bad Requst (400): Invalid value for: null is not a valid value

As well as the following dialogue between client and server:

POST /resumable/upload/youtube/v3/videos?part=status%2Csnippet&alt=json&uploadType=resumable HTTP/1.1
User-Agent: google-api-rust-client/0.1.6
Host: www.googleapis.com
Transfer-Encoding: chunked
Content-Type: application/json
X-Upload-Content-Type: application/octet-stream
Authorization: Bearer ya29.YwHqwwVjMrn7y_qO7d6RR5KeowbDJFO_2mLk5pTPs9iJZP0k3DEHUm6E4xkOv3pw5oEhX3GBjI-H4A

33C
{"status":{"license":"youtube","embeddable":true,"privacyStatus":"private","publishAt":null,"publicStatsViewable":null,"uploadStatus":null,"rejectionReason":null,"failureReason":null},"topicDetails":null,"monetizationDetails":null,"suggestions":null,"ageGating":null,"fileDetails":null,"player":null,"id":null,"localizations":null,"liveStreamingDetails":null,"snippet":{"description":"TBD","tags":["Google APIs, Google, rust-lang, Diary, OSS"],"channelId":null,"defaultLanguage":null,"liveBroadcastContent":null,"publishedAt":null,"thumbnails":null,"title":"Google APIs for Rust: Developer Diary #2 [Making CLIs]","categoryId":"22","localized":null,"channelTitle":null},"kind":null,"statistics":null,"projectDetails":null,"conversionPings":null,"processingDetails":null,"etag":null,"contentDetails":null,"recordingDetails":null}
0

HTTP/1.1 400 Bad Request
Vary: Origin
Vary: X-Origin
Content-Type: application/json; charset=UTF-8
Content-Length: 234
Date: Tue, 28 Apr 2015 06:31:59 GMT
Server: UploadServer ("Built on Apr 20 2015 22:37:13 (1429594633)")
Alternate-Protocol: 443:quic,p=1

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid value for: null is not a valid value"
   }
  ],
  "code": 400,
  "message": "Invalid value for: null is not a valid value"
 }
}

As you can see, the request contains null values which are not allowed.

To further stress the importance of this feature, have a look at the respective Go implementation ...

type AccessPolicy struct {
    // Allowed: The value of allowed indicates whether the access to the
    // policy is allowed or denied by default.
    Allowed bool `json:"allowed,omitempty"`

    // Exception: A list of region codes that identify countries where the
    // default policy do not apply.
    Exception []string `json:"exception,omitempty"`
}

... where the marker omitempty will prevent it to be serialized if unset.

You can try it yourself using the youtube3 program, which can be downloaded here.

Serialization for human consumption

Right now there is exactly one method to get 'pretty', i.e. more human-friendly json output. It provides no option to specify how exactly that could be done.

The most prominent one to me would be a setting for whether or not to ignore null values. Other options could be the indentation string to use, e.g. \t or .

Motivation

When printing the server response of any of the various google apis using a generated command-line interface, simple invocation yield results like this:

$ discovery1 apis get-rest discovery v1
{
  "protocol": "rest",
  "methods": null,
  "labels": null,
  "kind": "discovery#restDescription",
  "canonicalName": null,
  "ownerName": "Google",
  "documentationLink": "https://developers.google.com/discovery/",
  "auth": null,
  "packagePath": null,
  "batchPath": "batch",
  "id": "discovery:v1",
  "features": null,
  "ownerDomain": "google.com",
  "rootUrl": "https://www.googleapis.com/",
  "name": "discovery",
  "parameters": {
    "key": {
      "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
      "format": null,
      "enum": null,
      "variant": null,
      "enumDescriptions": null,
      "readOnly": null,
      "minimum": null,
      "repeated": null,
      "id": null,
      "$ref": null,
      "default": null,
      "items": null,
      "required": null,
      "maximum": null,
      "properties": null,
      "location": "query",
      "pattern": null,
      "additionalProperties": null,
      "type": "string",
      "annotations": null
    },
    "userIp": {
      "description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.",
      "format": null,
      "enum": null,
      "variant": null,
      "enumDescriptions": null,
      "readOnly": null,
      "minimum": null,
      "repeated": null,
      "id": null,
      "$ref": null,
      "default": null,
      "items": null,
      "required": null,
      "maximum": null,
      "properties": null,
      "location": "query",
      "pattern": null,
      "additionalProperties": null,
      "type": "string",
      "annotations": null
    },
  [...]
  "revision": null
}

The above should look like this:

$ discovery1 apis get-rest discovery v1
{
 "kind": "discovery#restDescription",
 "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/rJ-Wlqqs_yJDjtCFAIylPtmqXPY\"",
 "discoveryVersion": "v1",
 "id": "discovery:v1",
 "name": "discovery",
 "version": "v1",
 "title": "APIs Discovery Service",
 "description": "Lets you discover information about other Google APIs, such as what APIs are available, the resource and method details for each API.",
 "ownerDomain": "google.com",
 "ownerName": "Google",
 "icons": {
  "x16": "http://www.google.com/images/icons/feature/filing_cabinet_search-g16.png",
  "x32": "http://www.google.com/images/icons/feature/filing_cabinet_search-g32.png"
 },
 "documentationLink": "https://developers.google.com/discovery/",
 "protocol": "rest",
 "baseUrl": "https://www.googleapis.com/discovery/v1/",
 "basePath": "/discovery/v1/",
 "rootUrl": "https://www.googleapis.com/",
 "servicePath": "discovery/v1/",
 "batchPath": "batch",
 "parameters": {
  "alt": {
   "type": "string",
   "description": "Data format for the response.",
   "default": "json",
   "enum": [
    "json"
   ],
   "enumDescriptions": [
    "Responses with Content-Type of application/json"
   ],
   "location": "query"
  },
  "fields": {
   "type": "string",
   "description": "Selector specifying which fields to include in a partial response.",
   "location": "query"
  },
  "key": {
   "type": "string",
   "description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
   "location": "query"
  },
  "oauth_token": {
   "type": "string",
   "description": "OAuth 2.0 token for the current user.",
   "location": "query"
  },
  "prettyPrint": {
   "type": "boolean",
   "description": "Returns response with indentations and line breaks.",
   "default": "true",
   "location": "query"
  },
  "quotaUser": {
   "type": "string",
   "description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.",
   "location": "query"
  },
  "userIp": {
   "type": "string",
   "description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.",
   "location": "query"
  }
 },
 "schemas": {
  "DirectoryList": {
   "id": "DirectoryList",
   "type": "object",
   "properties": {
    "discoveryVersion": {
     "type": "string",
     "description": "Indicate the version of the Discovery API used to generate this doc.",
     "default": "v1"
    },
    "items": {
     "type": "array",
     "description": "The individual directory entries. One entry per api/version pair.",
     "items": {
      "type": "object",
      "properties": {
       "description": {
        "type": "string",
        "description": "The description of this API."
       },
       "discoveryLink": {
        "type": "string",
        "description": "A link to the discovery document."
       },
       "discoveryRestUrl": {
        "type": "string",
        "description": "The URL for the discovery REST document."
       },
       "documentationLink": {
        "type": "string",
        "description": "A link to human readable documentation for the API."
       },
       "icons": {
        "type": "object",
        "description": "Links to 16x16 and 32x32 icons representing the API.",
        "properties": {
         "x16": {
          "type": "string",
          "description": "The URL of the 16x16 icon."
         },
         "x32": {
          "type": "string",
          "description": "The URL of the 32x32 icon."
         }
        }
       },
       "id": {
        "type": "string",
        "description": "The id of this API."
       },
       "kind": {
        "type": "string",
        "description": "The kind for this response.",
        "default": "discovery#directoryItem"
       },
       "labels": {
        "type": "array",
        "description": "Labels for the status of this API, such as labs or deprecated.",
        "items": {
         "type": "string"
        }
       },
       "name": {
        "type": "string",
        "description": "The name of the API."
       },
       "preferred": {
        "type": "boolean",
        "description": "True if this version is the preferred version to use."
       },
       "title": {
        "type": "string",
        "description": "The title of this API."
       },
       "version": {
        "type": "string",
        "description": "The version of the API."
       }
      }
     }
    },
    "kind": {
     "type": "string",
     "description": "The kind for this response.",
     "default": "discovery#directoryList"
    }
   }
  },
 [...]
}

per field attributes

Brought up by WalrusPony in IRC. Fields in JSON may be conflict with keywords in Rust. One solution might be to append an attribute on a field, specifying the name that should be used in deriving.

#[deriving(Serializable, Deserializable)]
struct Foo {
    bar: u32,
    #[serde(name="mod")]
    mod_: String,
}

Replace serde with serde2

Meta issue to track what's left to be done to replace serde with serde2:

  • Get generics to work with macros
  • Migrate the tests
  • Get all the json tests to work
  • Add json pretty printer

Wrong type value in data reported as "expected value" at line 0 column 0

When reading data that is the wrong type, the error reported is opaque, and doesn't give a valid location. This makes debugging hard and makes it difficult to report meaningful errors to a user of a program.

An example of this is reading {"a": "b"} for struct S {a: Option<u32>}, but the issue seems to be more general than this particular example.

Option values don't round trip through json

Parsing data into an option value seems to fail, with "SyntaxError("expected value", 0, 0)":

#![feature(custom_attribute, plugin)]
#![plugin(serde2_macros)]

extern crate serde2;

use serde2::json;

#[derive(Debug)]
#[derive_deserialize]
#[derive_serialize]
pub struct Struct {
    a: Option<u32>,
}

#[test]
fn it_works() {
    let v = Struct { a: Some(32) };
    let s = json::to_string(&v).unwrap();
    assert_eq!("{\"a\":32}", s);
    // This fails
    let data : Struct = json::from_str(&s[..]).unwrap();
}

deserialize: flexible defaults for missing struct fields

Currently I have to define a newtype (eg: "BoolDefaultTrue") every time I want an optional struct field to have a non-Default::default() default, which is clumsy. Ideally I could just say something like:

struct Foo {
    #[serde(default=true)]
    enabled: bool,
}

... and this would fill in the value true if it was missing from the serialised string. Super-awesome would be if serde also generated a Default trait implementation for Foo that respected the same values, but I could understand that being considered out of scope.

Integer overflow when parsing JSON scientific notation number

This is a different issue from #75

Code

#![feature(plugin)]
#![plugin(afl_coverage_plugin)]

extern crate afl_coverage;

extern crate serde;

use std::io::{self, Read, Cursor};

use serde::json::{self, Value};


fn main() {
    let mut input = String::new();
    let result = io::stdin().read_to_string(&mut input);
    if result.is_ok() {
        if let Ok(j) = json::from_str::<json::Value>(&input) {
            let _ = json::to_string(&j);
        }
    }
}

Input

[7E-7777777777]

Crash

root@vultr:~/afl-staging-area2# cargo run < outputs/crashes/id\:000008*
     Running `target/debug/afl-staging-area2`
thread '<main>' panicked at 'arithmetic operation overflowed', /root/serde/serde/src/json/de.rs:270
An unknown error occurred

To learn more, run the command again with --verbose.

This bug was found using https://github.com/kmcallister/afl.rs ๐Ÿ‘

#[derive(Deserialize)] source map contains nonexistent files

The source map generated from usage of #[derive(Deserialize)] causes .d files emitted by the compiler to contain nonexistent files that look like:

/home/alex/code/example/home/alex/code/example/target/debug/libexample.rlib: src/lib.rs <quote\ expansion <quote\ expansion <quote\ expansion <quote\ expansion

/home/alex/code/example/target/debug/example.d: src/lib.rs <quote\ expansion <quote\ expansion <quote\ expansion <quote\ expansion

(e.g. <quote expansion). Unfortunately this causes Cargo to think that <quote expansion is an input file, and because it never exists Cargo will always rebuild a library using #[derive(Deserialize)].

I think this may originally come from quasi, but I'm not sure if it's because of quasi or something in the middle?

Cannot derive Serialize or Deserialize for a certain type of Enum

If there's a lifetime parameter in one variant of Enum and not in another, deriving either Serialize or Deserialize results in an compilation error.

#[derive(Serialize)]
enum Test<'a> {
    LifeTime(&'a str),
    NoLifeTime(i32),
}

Resulting error:

<quote expansion:1:2: 1:4 error: parameter `'a` is never used [E0392]
<quote expansion:1 <'a:'__a, '__a>
                    ^~
src/main.rs:8:10: 8:19 note: in expansion of #[derive_Serialize]
src/main.rs:8:10: 8:19 note: expansion site
<quote expansion:1:2: 1:4 help: consider removing `'a` or using a marker such as `core::marker::PhantomData`

JSON serialization could skip serializing "null" fields

Right now we serialize a type like:

struct Foo {
    x: ()
}

As:

{"x": null}

But many json deserializers (like serde) support treating missing fields as a null value. If we could do this efficiently in serde, then we could cut down on the size of our serialized output. Unfortunately this would require us to add some form of lookahead to Serializer, which might be tricky.

Using #[derive_serialize] results in undeclared type and trait errors

The following gives errors.

#[derive_serialize]
struct S {
    a: String,
    b: u32
}
src/lib.rs:10:5: 10:24 error: failed to resolve. Use of undeclared type or module `serde::ser`
src/lib.rs:10     #[derive_serialize]
                  ^~~~~~~~~~~~~~~~~~~
src/lib.rs:10:5: 10:24 note: in expansion of #[derive_serialize]
src/lib.rs:10:5: 10:24 note: expansion site
src/lib.rs:10:5: 10:24 error: use of undeclared trait name `serde::ser::Serializer`
src/lib.rs:10     #[derive_serialize]
                  ^~~~~~~~~~~~~~~~~~~
src/lib.rs:10:5: 10:24 note: in expansion of #[derive_serialize]
src/lib.rs:10:5: 10:24 note: expansion site

Serde2 fails to compile on latest nightly

Serde2 fails to compile with rustc (2b01a37ec 2015-02-21).

Some of the errors are coming from templated structs with no data members. eg. pub struct PrimitiveVisitor<T>; is giving "error: parameter T is never used".

I have been unable to come up with a way of imlpementing the functionality required of these structs, and was wondering if anyone had found a workaround?

Add primitive array wrapper type

Some formats can serialize a type like &[u8] more compactly than a generic &[T] type. Since we don't have specialization yet, instead we should provide a simple wrapper type that adds hooks to enable this pseudo-specialization.

Fail to build serde_macros

When update Cargo.toml to get serdes_macro, it fails to build:

    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling aster v0.3.0
     Running `rustc C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\aster-0.3.0\src\lib.rs --crate-name aste
r --crate-type lib -g -C metadata=4062c74cb2dc9294 -C extra-filename=-4062c74cb2dc9294 --out-dir D:\Code\projects\badger
GP\target\debug\deps --emit=dep-info,link -L dependency=D:\Code\projects\badgerGP\target\debug\deps -L dependency=D:\Cod
e\projects\badgerGP\target\debug\deps -Awarnings`
   Compiling quasi v0.3.0
     Running `rustc C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs --crate-name quas
i --crate-type lib -g -C metadata=ffe22e38403c370f -C extra-filename=-ffe22e38403c370f --out-dir D:\Code\projects\badger
GP\target\debug\deps --emit=dep-info,link -L dependency=D:\Code\projects\badgerGP\target\debug\deps -L dependency=D:\Cod
e\projects\badgerGP\target\debug\deps -Awarnings`
       Fresh strsim v0.3.0
       Fresh libc v0.1.8
       Fresh regex v0.1.30
       Fresh rustc-serialize v0.3.14
       Fresh rand v0.3.8
       Fresh docopt v0.6.64
       Fresh num v0.1.24
       Fresh serde v0.4.0
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:112:58: 112:75 error: unresolved name
 `token::NtImplItem`
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:112         vec![ast::TtToken(self.sp
an, token::Interpolated(token::NtImplItem(self.clone())))]

                        ^~~~~~~~~~~~~~~~~
<std macros>:1:1: 4:58 note: in expansion of vec!
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:112:9: 112:92 note: expansion site
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:118:58: 118:76 error: unresolved name
 `token::NtTraitItem`
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:118         vec![ast::TtToken(self.sp
an, token::Interpolated(token::NtTraitItem(self.clone())))]

                        ^~~~~~~~~~~~~~~~~~
<std macros>:1:1: 4:58 note: in expansion of vec!
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:118:9: 118:93 note: expansion site
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:169:57: 169:69 error: unresolved name
 `token::NtArm`
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:169         vec![ast::TtToken(DUMMY_S
P, token::Interpolated(token::NtArm(self.clone())))]

                       ^~~~~~~~~~~~
<std macros>:1:1: 4:58 note: in expansion of vec!
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\lib.rs:169:9: 169:86 note: expansion site
error: aborting due to 3 previous errors
Build failed, waiting for other jobs to finish...
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\aster-0.3.0\src\lib.rs:1:43: 1:66 error: unstable feature
C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\aster-0.3.0\src\lib.rs:1 #![cfg_attr(not(feature = "with-syn
tex"), feature(rustc_private))]

       ^~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the stable release channel
error: aborting due to previous error
Could not compile `quasi`.

Caused by:
  Process didn't exit successfully: `rustc C:\Users\MB\.cargo\registry\src\github.com-1ecc6299db9ec823\quasi-0.3.0\src\l
ib.rs --crate-name quasi --crate-type lib -g -C metadata=ffe22e38403c370f -C extra-filename=-ffe22e38403c370f --out-dir
D:\Code\projects\badgerGP\target\debug\deps --emit=dep-info,link -L dependency=D:\Code\projects\badgerGP\target\debug\de
ps -L dependency=D:\Code\projects\badgerGP\target\debug\deps -Awarnings` (exit code: 101)

YAML Support

YAML support would be interesting for configuration files that wanted to use structured richer than TOML allows for, and also wanted to allow comments (which JSON doesn't).

visiting a struct field/map key twice silently overwrites the previous field value

{
    "inner": [ {
        "a": null,
        "b": 2, 
        "c": ["abc", "xyz"]
    } ],
    "inner": [ {
        "a": null,
        "b": 42,
        "c": ["cake", "lie"]
    } ]
}

parses to

Outer {
    inner: vec![
        Inner { a: (), b: 42, c: vec!["cake".to_string(), "lie".to_string()] }
    ]
}

without any troubles. For multimaps that is alright, as it would get appended, but normal maps and structs should error out.

Won't build on latest Nightly

Just a heads up. I was giving the lib a go today and stumbled with this error. I couldn't find the reason in the breaking changes log though.

Using rustc 0.13.0-nightly (126db549b 2014-12-15 00:07:35 +0000)

I get

   Compiling serde_macros v0.1.0 (file:///C:/Users/arthur.silva/Desktop/rust-serde-master)
src\lib.rs:116:15: 116:44 error: the trait `core::ops::Fn<(syntax::ptr::P<syntax::ast::Item>,), ()>` is not implemented for the type `|syntax::ptr::P<syntax::ast::Item>|`
src\lib.rs:116     trait_def.expand(cx, mitem, item, push)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src\lib.rs:247:15: 247:44 error: the trait `core::ops::Fn<(syntax::ptr::P<syntax::ast::Item>,), ()>` is not implemented for the type `|syntax::ptr::P<syntax::ast::Item>|`
src\lib.rs:247     trait_def.expand(cx, mitem, item, push)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
Could not compile `serde_macros`.

To learn more, run the command again with --verbose.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.