5 releases

Uses old Rust 2015

0.2.0 May 22, 2017
0.1.3 May 19, 2017
0.1.2 May 19, 2017
0.1.1 May 18, 2017
0.1.0 May 18, 2017

#2272 in Encoding

Download history 24/week @ 2024-07-29 62/week @ 2024-08-05 40/week @ 2024-08-12 15/week @ 2024-08-19 54/week @ 2024-08-26 27/week @ 2024-09-02 47/week @ 2024-09-09 17/week @ 2024-09-16 97/week @ 2024-09-23 46/week @ 2024-09-30 24/week @ 2024-10-07 30/week @ 2024-10-14 15/week @ 2024-10-21 60/week @ 2024-10-28 24/week @ 2024-11-04 7/week @ 2024-11-11

111 downloads per month
Used in cobalt-bin

MIT/Apache

43KB
975 lines

JSON Feed Parser

[link=https://github.com/pwoolcoc/jsonfeed] JSON Feed crate version

This is a JSON Feed parser in Rust. Just a thin layer on top of serde, but it provides serialization & deserialization, along with a Builder API for constructing feeds.

Note that this is alpha, I still need to add a lot of tests and a couple more features.

Example

extern crate jsonfeed;
extern crate reqwest;

fn main() {
	let resp = reqwest::get("https://example.com/feed.json").unwrap();
	let feed = jsonfeed::from_reader(resp).unwrap();
	println!("Feed title is: {}", feed.title);
}

TODO:

  • Tests. Lots and lots of tests
  • Implement ability to add, serialize, and deserialize custom attributes from the json feed spec

lib.rs:

JSON Feed is a syndication format similar to ATOM and RSS, using JSON instead of XML

This crate can serialize and deserialize between JSON Feed strings and Rust data structures. It also allows for programmatically building a JSON Feed

Example:

extern crate jsonfeed;

use jsonfeed::{Feed, Item};

fn run() -> Result<(), jsonfeed::Error> {
    let j = r#"{
        "title": "my feed",
        "version": "https://jsonfeed.org/version/1",
        "items": []
    }"#;
    let feed = jsonfeed::from_str(j).unwrap();

    let new_feed = Feed::builder()
                        .title("some other feed")
                        .item(Item::builder()
                                .title("some item title")
                                .content_html("<p>Hello, World</p>")
                                .build()?)
                        .item(Item::builder()
                                .title("some other item title")
                                .content_text("Hello, World!")
                                .build()?)
                        .build();
    println!("{}", jsonfeed::to_string(&new_feed).unwrap());
    Ok(())
}
fn main() {
    let _ = run();
}

Dependencies

~3–9.5MB
~99K SLoC