<commit_before>#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]

extern crate serde;
extern crate ease;

use std::collections::HashMap;
use ease::RestClient;

#[derive(Deserialize, Debug)]
struct Response {
    args: HashMap<String, String>,
    headers: HashMap<String, String>,
    origin: String,
    url: String
}

fn main() {
    println!("{:?}",
             RestClient::new("http://httpbin.org/get")
                        .ok().expect("Couldn't parse URL.")
                        .get_json_as::<Response>()
                        .unwrap()
        );
}<commit_msg>Add JSON and POST example.<commit_after>#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]

extern crate serde;
extern crate ease;

use std::collections::HashMap;
use ease::RestClient;

#[derive(Deserialize, Debug)]
struct Response {
    args: HashMap<String, String>,
    data: Option<String>,
    files: HashMap<String, String>,
    form: HashMap<String, String>,
    headers: HashMap<String, String>,
    json: Option<String>,
    origin: String,
    url: String
}

fn main() {
    println!("{:?}",
             RestClient::new("http://httpbin.org/post")
                        .ok().expect("Couldn't parse URL.")
                        .post_json_as::<Response>()
        );
    
    println!("{:?}",
             RestClient::new("http://httpbin.org/get")
                        .ok().expect("Couldn't parse URL.")
                        .get_json_as::<Response>()
        );
}
{'fraction_non_alphanumeric': 0.16272788656313303, 'fraction_numerical': 0.0, 'mean_word_length': 2.4385150812064964, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1253590', 'n_tokens_mistral': 443, 'n_tokens_neox': 440, 'n_words': 91}