auto merge of #12780 : zslayton/rust/json-nav, r=alexcrichton
auto merge of #12780 : zslayton/rust/json-nav, r=alexcrichton

This is my first non-docs contribution to Rust, so please let me know what I can fix. I probably should've submitted this to the mailing list first for comments, but it didn't take too long to implement so I figured I'd just give it a shot.

These changes are modeled loosely on the [JsonNode API](http://jackson.codehaus.org/1.7.9/javadoc/org/codehaus/jackson/JsonNode.html) provided by the [Jackson JSON processor](http://jackson.codehaus.org/).

Many common use cases for parsing JSON involve pulling one or more fields out of an object, however deeply nested. At present, this requires writing a pyramid of match statements. The added methods in this PR aim to make this a more painless process.

**Edited to reflect final implementation**

Example JSON:
```json
{
    "successful" : true,
    "status" : 200,
    "error" : null,
    "content" : {
        "vehicles" : [
            {"make" : "Toyota", "model" : "Camry", "year" : 1997},
            {"make" : "Honda", "model" : "Accord", "year" : 2003}
        ]
    }
}
```

Accessing "successful":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let was_successful: Option<bool> = example_json.find(&~"successful").and_then(|j| j.as_boolean());
```

Accessing "status":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let status_code : Option<f64> = example_json.find(&~"status").and_then(|j| j.as_number());
```

Accessing "vehicles":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let vehicle_list: Option<List> = example_json.search(&~"vehicles").and_then(|j| j.as_list());
```

Accessing "vehicles" with an explicit path:
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let vehicle_list: Option<List> = example_json.find_path(&[&~"content", &~"vehicles"]).and_then(|j| j.as_list());
```

Accessing "error", which might be null or a string:
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let error: Option<Json> = example_json.find(&~"error");
 if error.is_null() { // This would be nicer as a match, I'm just illustrating the boolean test methods
    println!("Error is null, everything's fine.");
 } else if error.is_str(){
    println!("Something went wrong: {}", error.as_string().unwrap());
}
```

Some notes:
* Macros would help to eliminate some of the repetitiveness of the implementation, but I couldn't use them due to #4621. (**Edit**: There is no longer repetitive impl. Methods were simplified to make them more composable.)
* Would it be better to name methods after the Json enum type (e.g. `get_string`) or the associated Rust built-in? (e.g. `get_str`)
* TreeMap requires its keys to be &~str. Because of this, all of the new methods required &~str for their parameters. I'm uncertain what the best approach to fixing this is: neither demanding an owned pointer nor allocating within the methods to appease TreeMap's find() seems desirable. If I were able to take &str, people could put together paths easily with `"foo.bar.baz".split('.').collect();` (**Edit**: Follow on investigation into making TreeMap able to search by Equiv would be worthwhile.)
* At the moment, the `find_<sometype>` methods all find the first match for the provided key and attempt to return that value if it's of the specified type. This makes sense to me, but it's possible that users would interpret a call to `find_boolean("successful")` as looking for the first "successful" item that was a boolean rather than looking for the first "successful" and returning None if it isn't boolean. (**Edit**: No longer relevant.)

I hope this is helpful. Any feedback is appreciated! 

krzysz00/rust,michaelballantyne/rust-gpu,servo/rust,dinfuehr/rust,gifnksm/rust,ejjeong/rust,jashank/rust,emk/rust,pczarn/rust,pelmers/rust,GBGamer/rust,jbclements/rust,bombless/rust-docs-chinese,zubron/rust,nham/rust,mdinger/rust,omasanori/rust,omasanori/rust,defuz/rust,untitaker/rust,kimroen/rust,seanrivera/rust,mahkoh/rust,omasanori/rust,aneeshusa/rust,nwin/rust,jbclements/rust,AerialX/rust,KokaKiwi/rust,jbclements/rust,retep998/rand,carols10cents/rust,0x73/rust,pelmers/rust,GrahamDennis/rand,erickt/rust,TheNeikos/rust,omasanori/rust,richo/rust,XMPPwocky/rust,TheNeikos/rust,michaelballantyne/rust-gpu,rohitjoshi/rust,graydon/rust,nham/rust,zaeleus/rust,kimroen/rust,mihneadb/rust,andars/rust,richo/rust,philyoon/rust,ktossell/rust,pczarn/rust,jashank/rust,aneeshusa/rust,jroesch/rust,omasanori/rust,pythonesque/rust,zubron/rust,dwillmer/rust,victorvde/rust,barosl/rust,kimroen/rust,defuz/rust,sae-bom/rust,gifnksm/rust,dwillmer/rust,servo/rust,gifnksm/rust,rohitjoshi/rust,XMPPwocky/rust,jroesch/rust,omasanori/rust,defuz/rust,michaelballantyne/rust-gpu,ktossell/rust,cllns/rust,pythonesque/rust,reem/rust,l0kod/rust,TheNeikos/rust,philyoon/rust,ebfull/rand,mahkoh/rust,l0kod/rust,zachwick/rust,GBGamer/rust,zaeleus/rust,ejjeong/rust,nwin/rust,victorvde/rust,ktossell/rust,kwantam/rust,P1start/rust,aneeshusa/rust,cllns/rust,KokaKiwi/rust,ejjeong/rust,jroesch/rust,aepsil0n/rust,vhbit/rust,pczarn/rust,jbclements/rust,aturon/rust,TheNeikos/rust,seanrivera/rust,rohitjoshi/rust,krzysz00/rust,sae-bom/rust,aneeshusa/rust,GBGamer/rust,mvdnes/rust,GBGamer/rust,andars/rust,dwillmer/rust,untitaker/rust,nham/rust,huonw/rand,nham/rust,jbclements/rust,nwin/rust,aepsil0n/rust,pythonesque/rust,philyoon/rust,emk/rust,miniupnp/rust,KokaKiwi/rust,bombless/rust,seanrivera/rust,cllns/rust,ruud-v-a/rust,rprichard/rust,pshc/rust,AerialX/rust-rt-minimal,mahkoh/rust,cllns/rust,waynenilsen/rand,michaelballantyne/rust-gpu,kimroen/rust,erickt/rust,pshc/rust,jroesch/rust,sae-bom/rust,andars/rust,AerialX/rust-rt-minimal,carols10cents/rust,AerialX/rust-rt-minimal,michaelballantyne/rust-gpu,robertg/rust,rprichard/rust,XMPPwocky/rust,aepsil0n/rust,0x73/rust,sae-bom/rust,defuz/rust,l0kod/rust,erickt/rust,bombless/rust,hauleth/rust,miniupnp/rust,zachwick/rust,GBGamer/rust,stepancheg/rust-ide-rust,nwin/rust,ktossell/rust,barosl/rust,ktossell/rust,robertg/rust,AerialX/rust-rt-minimal,pshc/rust,graydon/rust,emk/rust,untitaker/rust,quornian/rust,servo/rust,Ryman/rust,zaeleus/rust,victorvde/rust,erickt/rust,bombless/rust,ejjeong/rust,P1start/rust,gifnksm/rust,mvdnes/rust,P1start/rust,vhbit/rust,rprichard/rust,barosl/rust,graydon/rust,servo/rust,aturon/rust,jroesch/rust,zubron/rust,GBGamer/rust,jashank/rust,graydon/rust,barosl/rust,rohitjoshi/rust,mdinger/rust,pelmers/rust,0x73/rust,reem/rust,jroesch/rust,avdi/rust,jashank/rust,rprichard/rust,zubron/rust,sae-bom/rust,0x73/rust,avdi/rust,rohitjoshi/rust,jbclements/rust,achanda/rand,nham/rust,mdinger/rust,XMPPwocky/rust,pelmers/rust,jbclements/rust,dinfuehr/rust,ebfull/rust,dinfuehr/rust,dinfuehr/rust,philyoon/rust,miniupnp/rust,kwantam/rust,aturon/rust,l0kod/rust,hauleth/rust,ruud-v-a/rust,zubron/rust,aepsil0n/rust,miniupnp/rust,servo/rust,kimroen/rust,jashank/rust,stepancheg/rust-ide-rust,quornian/rust,aturon/rust,AerialX/rust,KokaKiwi/rust,krzysz00/rust,carols10cents/rust,aidancully/rust,aidancully/rust,l0kod/rust,mahkoh/rust,rohitjoshi/rust,ebfull/rust,ebfull/rust,graydon/rust,avdi/rust,reem/rust,quornian/rust,avdi/rust,jashank/rust,philyoon/rust,aidancully/rust,bluss/rand,mdinger/rust,pczarn/rust,victorvde/rust,ejjeong/rust,dinfuehr/rust,stepancheg/rust-ide-rust,jashank/rust,pczarn/rust,0x73/rust,l0kod/rust,P1start/rust,aidancully/rust,nham/rust,jbclements/rust,dwillmer/rust,victorvde/rust,aneeshusa/rust,reem/rust,hauleth/rust,jroesch/rust,nwin/rust,pythonesque/rust,krzysz00/rust,mihneadb/rust,ruud-v-a/rust,miniupnp/rust,pshc/rust,carols10cents/rust,Ryman/rust,pczarn/rust,ebfull/rust,rprichard/rust,ktossell/rust,barosl/rust,KokaKiwi/rust,erickt/rust,nwin/rust,andars/rust,richo/rust,l0kod/rust,bombless/rust,kimroen/rust,AerialX/rust,sae-bom/rust,bombless/rust,victorvde/rust,carols10cents/rust,emk/rust,dwillmer/rust,andars/rust,KokaKiwi/rust,AerialX/rust,bombless/rust,aneeshusa/rust,mvdnes/rust,mvdnes/rust,ebfull/rust,aepsil0n/rust,vhbit/rust,hauleth/rust,0x73/rust,zubron/rust,aidancully/rust,untitaker/rust,michaelballantyne/rust-gpu,zachwick/rust,kwantam/rust,aturon/rust,philyoon/rust,zaeleus/rust,stepancheg/rust-ide-rust,seanrivera/rust,krzysz00/rust,mihneadb/rust,michaelballantyne/rust-gpu,richo/rust,emk/rust,stepancheg/rust-ide-rust,kwantam/rust,XMPPwocky/rust,pythonesque/rust,kwantam/rust,pshc/rust,AerialX/rust-rt-minimal,ruud-v-a/rust,miniupnp/rust,ruud-v-a/rust,robertg/rust,mdinger/rust,robertg/rust,andars/rust,XMPPwocky/rust,arthurprs/rand,zaeleus/rust,avdi/rust,untitaker/rust,mvdnes/rust,stepancheg/rust-ide-rust,vhbit/rust,aturon/rust,carols10cents/rust,cllns/rust,pythonesque/rust,P1start/rust,mdinger/rust,TheNeikos/rust,pelmers/rust,Ryman/rust,zubron/rust,aepsil0n/rust,miniupnp/rust,bhickey/rand,pczarn/rust,ktossell/rust,dinfuehr/rust,vhbit/rust,P1start/rust,GBGamer/rust,cllns/rust,pshc/rust,robertg/rust,l0kod/rust,erickt/rust,jbclements/rust,robertg/rust,aturon/rust,emk/rust,shepmaster/rand,miniupnp/rust,mvdnes/rust,seanrivera/rust,untitaker/rust,nwin/rust,nwin/rust,TheNeikos/rust,servo/rust,mahkoh/rust,richo/rust,servo/rust,Ryman/rust,zachwick/rust,zachwick/rust,ruud-v-a/rust,dwillmer/rust,stepancheg/rust-ide-rust,gifnksm/rust,vhbit/rust,gifnksm/rust,0x73/rust,aidancully/rust,emk/rust,richo/rust,pelmers/rust,graydon/rust,quornian/rust,pshc/rust,dwillmer/rust,hauleth/rust,zachwick/rust,quornian/rust,barosl/rust,krzysz00/rust,vhbit/rust,quornian/rust,Ryman/rust,mihneadb/rust,pshc/rust,mihneadb/rust,hauleth/rust,dwillmer/rust,mahkoh/rust,defuz/rust,zubron/rust,kimroen/rust,ejjeong/rust,kwantam/rust,barosl/rust,reem/rust,jashank/rust,avdi/rust,quornian/rust,reem/rust,Ryman/rust,nham/rust,ebfull/rust,vhbit/rust,pythonesque/rust,AerialX/rust-rt-minimal,rprichard/rust,AerialX/rust,defuz/rust,seanrivera/rust,P1start/rust,Ryman/rust,GBGamer/rust,mihneadb/rust,erickt/rust,zaeleus/rust,AerialX/rust,jroesch/rust