pub fn parse_post(data: &JsonValue) -> Option<Post> {
    let data = &data["data"];

    if data["post_hint"] != "image" && data["post_hint"] != "rich:video" {
        return None;
    }

    let author = data["author"].to_string();
    let title = data["title"].to_string();
    let permalink = data["permalink"].to_string();

    let nsfw = data["over_18"].as_bool().unwrap();

    let image = if data["url"].contains("gfycat.com") && data["post_hint"] == "rich:video" {
        data["secure_media"]["oembed"]["thumbnail_url"].to_string()
    } else {
        data["url"].to_string()
    };

    let ups = data["ups"].as_u64().unwrap();

    Some(Post::new(&author, &title, &image, &permalink, nsfw, ups))
}
// turns raw json into a Post object
turns raw json into a Post object
turns raw json into a Post object
pub fn parse_post(data: &JsonValue) -> Option<Post> {
    let data = &data["data"];
    if data["post_hint"] != "image" && data["post_hint"] != "rich:video" {
        return None;
    }
    let author = data["author"].to_string();
    let title = data["title"].to_string();
    let permalink = data["permalink"].to_string();
    let nsfw = data["over_18"].as_bool().unwrap();
    let image = if data["url"].contains("gfycat.com") && data["post_hint"] == "rich:video" {
        data["secure_media"]["oembed"]["thumbnail_url"].to_string()
    } else {
        data["url"].to_string()
    };
    let ups = data["ups"].as_u64().unwrap();
    Some(Post::new(&author, &title, &image, &permalink, nsfw, ups))
}
pub fn parse_post ( data : & JsonValue ) -> Option < Post > { let data = & data [ " " ] ; if data [ " " ] != " " && data [ " " ] != " " { return None ; } let author = data [ " " ] . to_string ( ) ; let title = data [ " " ] . to_string ( ) ; let permalink = data [ " " ] . to_string ( ) ; let nsfw = data [ " " ] . as_bool ( ) . unwrap ( ) ; let image = if data [ " " ] . contains ( " " ) && data [ " " ] == " " { data [ " " ] [ " " ] [ " " ] . to_string ( ) } else { data [ " " ] . to_string ( ) } ; let ups = data [ " " ] . as_u64 ( ) . unwrap ( ) ; Some ( Post :: new ( & author , & title , & image , & permalink , nsfw , ups ) ) }
turns raw json into a Post object
turns raw json into a Post object
data
&JsonValue