Mapping RSS and Atom to JSON Feed
Though RSS and Atom are XML and JSON Feed isn’t, there are a number of similarities. Here’s how to map them.
RSS
Channel
While RSS has a channel
top-level element, JSON Feed puts the corresponding information at the top level.
RSS
title
anddescription
map directly to JSON. An RSSlink
maps tohome_page_url
.cloud
element is similar in purpose to the JSON Feedhubs
item.RSS has
webmaster
andmanagingEditor
items, while JSON Feed has anauthor
item.image
is superficially like a JSON Feedicon
— except that the JSON Feed version should be square, and the RSS image should be wider than it is tall. These map only in the case that your RSS image is already square.
Item
RSS has an array of item
objects, and so does JSON Feed.
title
maps directly, with the caveat that it must be plain text in JSON Feed. (Note:title
is optional in both RSS and JSON Feed.)link
maps tourl
and toexternal_url
. Theurl
must be a permalink, a link to the content of the item. When an item links to another page — as in a linkblog — thenexternal_url
must be the URL of that other page. (See the Daring Fireball JSON feed for an example.)description
maps tocontent_html
and tocontent_text
. Choose the one that fits. A Twitter-like service might usecontext_text
, while a blog might usecontent_html
.guid
maps toid
. In RSS,guid
can have anisPermaLink
attribute; in JSON Feed theurl
must be the permalink, andid
may be the same asurl
, though it doesn’t have to be.The
author
element is a single value, while in JSON Feed it’s an object withname
,url
, andavatar
values.pubDate
maps todate_published
, but this date and others in JSON Feed use a different format, the RFC 3339 format. (Example:2010-02-07T14:04:00-05:00
.)enclosure
maps toattachments
— but JSON Feed allows for multiple attachments. An RSSenclosure
has attributesurl
,length
, andtype
, and the JSON Feed attachment object has corresponding elementsurl
,size_in_bytes
, andmime_type
. JSON Feed addstitle
andduration_in_seconds
.category
maps totags
. In RSS acategory
can have adomain
attribute, and there’s no equivalent in JSON Feed.
Atom
Feed
Unlike RSS’s channel
element, Atom puts many of the elements to describe a feed at the top level of the document, just like JSON Feed.
Atom’s
title
maps directly to JSON Feed.Atom uses
link
elements to show the relationship between the feed and other URLs. Without arel
attribute, or withrel="alternate"
, Atom’slink
is equivalent to JSON Feed’shome_page_url
. Withrel="self"
, it maps to JSON Feed’sfeed_url
.Atom has
subtitle
andid
elements. There is no mapping for these in JSON Feed, althoughdescription
in JSON could be used instead ofsubtitle
.For WebSub, Atom uses
link
elements withrel="hub"
. JSON Feed has a dedicatedhubs
array.
Entry
Atom has an array of entry
objects. In JSON Feed these are item
objects.
Atom’s
title
,id
, andsummary
map directly to JSON. In JSON, however,title
andsummary
are always plain text.Atom uses a content’s
type
attribute to declare whether the text is plain text or HTML.type="html"
ortype="xhtml"
in an Atom feed maps tocontent_html
in JSON.type="text"
maps tocontent_text
in JSON.link
withrel="alternate"
maps tourl
in JSON. Ifrel="related"
is used for links to an external site, in JSON Feed those map toexternal_url
.The
author
element containsname
,uri
, andemail
, while in JSON Feed it’s an object withname
,url
, andavatar
values.Atom’s
published
andupdated
dates map todate_published
anddate_modified
in JSON. Both Atom and JSON Feed use the same date format.Atom’s
link
withrel="enclosure"
maps toattachments
in JSON Feed. An Atom enclosure has attributeshref
,length
, andtype
, and the JSON Feed attachment object has corresponding elementsurl
,size_in_bytes
, andmime_type
. JSON Feed addstitle
andduration_in_seconds
.