Install rss-to-json via npm or yarn
masterYou can install the rss-to-json utility using either npm or yarn to add it to your project dependencies.
npm install rss-to-json --save
# or
yarn add rss-to-jsonrepository·master·Indexed 41 days ago
https://github.com/nasa8x/rss-to-jsonA Node.js utility for parsing ATOM and RSS feed resources and normalizing them into a consistent JSON object format. Version 2.1.1 provides a parse function that supports async/await and Promise-based syntax to convert feed URLs into JSON containing top-level metadata and an items array.
You can install the rss-to-json utility using either npm or yarn to add it to your project dependencies.
npm install rss-to-json --save
# or
yarn add rss-to-jsonThe parse function converts ATOM and RSS feed resources into a normalized JSON object. It supports both async/await and Promise-based syntax.
To use it, import parse from rss-to-json and pass the URL of the feed as a string.
const { parse } = require('rss-to-json');
// Using async/await
(async () => {
var rss = await parse('https://blog.ethereum.org/feed.xml');
console.log(JSON.stringify(rss, null, 3));
})();If you prefer not to use async/await, you can use the .then() method on the Promise returned by parse().
const { parse } = require('rss-to-json');
parse('https://blog.ethereum.org/feed.xml').then(rss => {
console.log(JSON.stringify(rss, null, 3));
});Each object within the items array in the conversion result contains the following fields:
title: The title of the feed item.description: The content or summary of the item.link: The URL to the item.published: The publication date as a Unix timestamp (milliseconds).created: The creation date as a Unix timestamp (milliseconds).category: An array of categories associated with the item.enclosures: An array of enclosure data.media: An object containing media information.When converting an RSS feed using rss-to-json, the resulting JSON object follows a specific structure. It contains top-level metadata about the feed and an items array containing the individual feed entries.
{
"title": "Feed Title",
"description": "Feed Description",
"link": "https://example.com",
"image": "https://example.com/image.png",
"category": [],
"items": [
{
"title": "Item Title",
"description": "Item Description",
"link": "https://example.com/item",
"published": 1626332400000,
"created": 1626332400000,
"category": [],
"enclosures": [],
"media": {}
}
]
}The parse function is the primary entrypoint for converting RSS or Atom feeds into normalized JSON objects. You can import it as a default export or as a named export parse from the package.
import parse from 'rss-to-json';
// Usage example (conceptual based on API surface)
const result = await parse(rssUrl);parse function and a named Parse entity (which may be the same function or a class depending on the implementation in ./parse). Use export { parse, Parse } to access these specifically.