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

#2229 in Encoding

Download history 18/week @ 2024-03-25 74/week @ 2024-04-01 23/week @ 2024-04-08 63/week @ 2024-04-15 29/week @ 2024-04-22 76/week @ 2024-04-29 24/week @ 2024-05-06 23/week @ 2024-05-13 20/week @ 2024-05-20 59/week @ 2024-05-27 24/week @ 2024-06-03 34/week @ 2024-06-10 19/week @ 2024-06-17 16/week @ 2024-06-24 100/week @ 2024-07-01 39/week @ 2024-07-08

180 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–5MB
~106K SLoC