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
247 downloads per month
Used in cobalt-bin
43KB
975 lines
JSON Feed Parser
[link=https://github.com/pwoolcoc/jsonfeed]
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