I'm playing around with the Twitch API in Rust, but I can't manage to get a correct JSON output from the response.
extern crate curl;
use curl::http;
fn main() {
let url = "http://api.twitch.tv/kraken/channels/twitch";
let resp = http::handle()
.get(url)
.exec().unwrap();
/* Prints StatusCode and Headers correctly. Print Body (requested json as numbers) */
println!("Code : {}\nHeaders : {:?}\nHeaders : {:?}\nBody : {:?}",
resp.get_code(), resp.get_header("content-length"), resp.get_headers(), resp.get_body());
/* Prints everything after each other and prints json correctly */
println!("{}", resp);
}
I don't understand why I get numbers as output instead of the JSON.
Example of output json:
[123, 34, 109, 97, 116, 117, 114, 101, 34, 58, 102, 97, 108]
Example of correct json:
{"mature":false,"status":"Twitch Weekly - 12/11/2015","broadcaster_language":"en"}
Example of the full output: https://bitbucket.org/snippets/adrianz/q88KM