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

#43 in #deserialize-json

Download history 24/week @ 2024-04-07 62/week @ 2024-04-14 31/week @ 2024-04-21 58/week @ 2024-04-28 38/week @ 2024-05-05 25/week @ 2024-05-12 22/week @ 2024-05-19 58/week @ 2024-05-26 27/week @ 2024-06-02 28/week @ 2024-06-09 23/week @ 2024-06-16 17/week @ 2024-06-23 97/week @ 2024-06-30 40/week @ 2024-07-07 14/week @ 2024-07-14 93/week @ 2024-07-21

247 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