Skip to content

Latest commit

 

History

History
79 lines (44 loc) · 3.55 KB

README.md

File metadata and controls

79 lines (44 loc) · 3.55 KB

RSS-in-JSON is a feed format

It's simply an RSS 2.0 feed that uses JSON syntax in place of XML.

Example

Here's an example of a RSS-in-JSON feed. It's the JSON representation of the Scripting News RSS 2.0 feed.

The general rule

An attribute of an element in the XML version is a property in the RSS-in-JSON object.

If an element has one or more attributes and a value, the value is represented as a property named #value.

If an element has a value and no attributes it's represented as a property in the JSON representation.

Illustrations of the general rule

  1. <enclosure> sub-element of <item> has attributes and no value. It is represented as:
"enclosure": {
   "url": "http://www.scripting.com/mp3s/weatherReportSuite.mp3",
   "length": 12216320,
   "type": "audio/mpeg"
   }
  1. <category> sub-element of <item> can contain both an attribute and a value.
"category": {
   "domain": "http://www.fool.com/cusips",
   "#value": "MSFT"
   }
  1. <pubDate> sub-element of <item> has a value and no attributes.
"pubDate": "Sun, 19 May 2002 15:21:36 GMT"

Scope

This document explains how an RSS 2.0 feed maps onto JSON syntax.

We'll describe the JavaScript object that the JSON is a representation of.

To create the JSON text from the RSS-in-JSON object:

jsontext = JSON.stringify (rssInJsonObject);

The rss object

The RSS-in-JSON object has a single property named rss. Its value is an object whose properties correspond to the attributes and sub-elements of the RSS 2.0 <rss> element.

rss has a property named version. Since we're representing an RSS 2.0 feed its value will be "2.0".

rss must also contain a property declaring each namespace it uses. The name of each begins with xmlns followed by : followed by the name you want to use for the namespace in the feed. The value is the URL used in the namespace declaration in the XML feed.

The rss object contains a property named channel, whose value is an object that has properties corresponding to the elements of <channel> in the RSS feed.

For example, it may contain a property named cloud whose value is an object with properties corresponding to the attributes of the RSS 2.0 <cloud> element.

The item array

channel may contain an aray named item. The elements of the array correspond to <item>s in the XML version.

Credits

Written by Dave Winer, reviewed by Allen Wirfs-Brock.

A blog post with background and links, re this document.

June 2017

Discussion, pointers

Dan MacTough did a schema for RSS-in-JSON.

If you have questions or comments please post an issue here.