Created
May 22, 2016 23:13
-
-
Save selfup/bb532c7bd9f36f7d2dfa4c1e457c1b3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rustc_serialize; | |
use rustc_serialize::json::{self, ToJson, Json}; | |
use std::collections::HashMap; | |
#[no_mangle] | |
pub extern fn read_json(ro: &'static str) -> String { | |
let roo = ro.to_string(); | |
let json_for_rust: HashMap<String, i32> = json::decode(&roo).unwrap(); | |
let encoded = json::encode(&json_for_rust).unwrap(); | |
encoded | |
} | |
#[test] | |
fn it_reads_the_json() { | |
let string = "{\"wow\":\"6\"}"; | |
let ro = string; | |
assert_eq!("{\"wow\":6}", read_object(ro)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment