Crate gqlog [โˆ’] [src]

gqlog

๐Ÿ‘พ filter your json logs with graphql ๐Ÿ‘พ

streams

extern crate serde_json;
extern crate gqlog;

use serde_json::de::{ StrRead };

fn main() {
    let query = String::from("{ foo }");
    let data = r#"{
        "foo": "bar",
        "baz": "buz"
    }"#;
    let reader = StrRead::new(data);

    gqlog::filter_stream::<StrRead>(query, reader, |value| {
        assert_eq!(value.to_string(), "{\"foo\":\"bar\"}");
    });
}

serde_json::Value

#[macro_use] extern crate serde_json;
extern crate gqlog;

fn main() {
    let query = String::from("{ foo }");
    let data = json!({
        "foo": "bar",
        "baz": "buz"
    });

    assert_eq!(gqlog::filter_value(query, data).to_string(), "{\"foo\":\"bar\"}");
}

JSON strings

extern crate serde_json;
extern crate gqlog;

fn main() {
    let query = String::from("{ foo }");
    let data = String::from(r#"{
        "foo": "bar",
        "baz": "buz"
    }"#);

    assert_eq!(gqlog::filter(query, data).to_string(), "{\"foo\":\"bar\"}");
}

Functions

filter

Filter a json string.

filter_stream

Filter a stream of JSON objects and trigger the callback for each.

filter_value

Filter a serde_json::Value.