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

#2055 in Encoding

Download history 16/week @ 2023-12-06 8/week @ 2023-12-13 6/week @ 2023-12-20 38/week @ 2023-12-27 14/week @ 2024-01-03 21/week @ 2024-01-10 11/week @ 2024-01-17 28/week @ 2024-01-24 9/week @ 2024-01-31 34/week @ 2024-02-07 20/week @ 2024-02-14 28/week @ 2024-02-21 100/week @ 2024-02-28 43/week @ 2024-03-06 37/week @ 2024-03-13 31/week @ 2024-03-20

220 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
~105K SLoC