1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![recursion_limit = "128"]
#[macro_use]
extern crate log;
extern crate regex;
#[macro_use]
extern crate serde;
extern crate serde_json;
mod ast;
mod avro;
mod bigquery;
mod jsonschema;
use serde_json::{json, Value};
fn into_ast(input: &Value) -> ast::Tag {
let jsonschema: jsonschema::Tag = match serde_json::from_value(json!(input)) {
Ok(tag) => tag,
Err(e) => panic!(format!("{:#?}", e)),
};
ast::Tag::from(jsonschema)
}
pub fn convert_avro(input: &Value) -> Value {
let avro = avro::Type::from(into_ast(input));
json!(avro)
}
pub fn convert_bigquery(input: &Value) -> Value {
let bq = bigquery::Tag::from(into_ast(input));
json!(bq)
}