You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
615 B
Rust
25 lines
615 B
Rust
extern crate nom;
|
|
|
|
use parser::template;
|
|
use std::io::{self, Read};
|
|
|
|
mod parser;
|
|
|
|
fn main() {
|
|
let context = read_context_from_stdin();
|
|
println!("{:?}", context);
|
|
}
|
|
|
|
fn read_context_from_stdin() -> serde_json::map::Map<String, serde_json::Value> {
|
|
let mut buffer = String::new();
|
|
io::stdin()
|
|
.read_to_string(&mut buffer)
|
|
.expect("Failed to read stdin");
|
|
|
|
let parsed: serde_json::Value = serde_json::from_str(&buffer).expect("Failed to parse json");
|
|
match parsed {
|
|
serde_json::Value::Object(obj) => obj,
|
|
_ => panic!("Expected context to be an object"),
|
|
}
|
|
}
|