The Abdera JSON Writer serializes Atom objects into a JSON format. The output depends largely on what Abdera Model object is being serialized. Null values are omitted from the output.
Example Serialization: http://www.snellspace.com/public/atom2json.txt
See also
http://www.ibm.com/developerworks/library/x-atom2json.html
Serializing org.apache.abdera.model.Document
Abdera abdera = new Abdera();
Document doc = ...
Writer writer = abdera.getWriterFactory().getWriter("json");
writer.writeTo(doc,System.out);
The fields correspond to the various getters on the Document object and represent information acquired primarily from the HTTP Headers of the source Atom document.
| Field |
Description |
| base |
The Base URI |
| charset |
The charset encoding |
| contenttype |
The MIME media type of the document |
| etag |
The Entity Tag of the document |
| lastmodified |
The number of milliseconds since the epoch indicating the value of the Last-Modified header |
| language |
The value of the Content-Language header |
| slug |
The value of the Slug header |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
| root |
json serialization of the root element |
Serializing org.apache.abdera.model.Feed
Abdera abdera = new Abdera();
Document<Feed> doc = ...
Feed feed = doc.getRoot();
Writer writer = abdera.getWriterFactory().getWriter("json");
writer.writeTo(feed,System.out);
Produces:
| Field |
Description |
| id |
The atom:id value |
| title |
serialization of the atom:title |
| subtitle |
serialization of the atom:subtitle |
| rights |
serialization of the atom:rights |
| updated |
number of milliseconds since the epoch, serialization of the atom:updated |
| generator |
serialization of atom:generator |
| icon |
absolute URI, serialization of atom:icon |
| logo |
absolute URI, serialization of atom:logo |
| authors |
array of serialized atom:author objects, see person serialization below |
| contributors |
array of serialized atom:contributor objects, see person serialization below |
| links |
array of serialized atom:link objects |
| categories |
array of serialized atom:category objects |
| complete |
true if the feed is marked with fh:complete from RFC 5005 |
| archive |
true if the feed is marked with fh:archive from RFC 5005 |
| entries |
array of serialized atom:entry objects |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
Serializing org.apache.abdera.model.Entry
Abdera abdera = new Abdera();
Document<Entry> doc = ...
Entry entry = doc.getRoot();
Writer writer = abdera.getWriterFactory().getWriter("json");
writer.writeTo(entry,System.out);
| Field |
Description |
| id |
The atom:id value |
| title |
serialization of the atom:title |
| summary |
serialization of the atom:summary |
| rights |
serialization of the atom:rights |
| updated |
number of milliseconds since the epoch, serialization of the atom:updated |
| published |
number of milliseconds since the epoch, serialization of the atom:published |
| edited |
number of milliseconds since the epoch, serialization of the app:edited |
| authors |
array of serialized atom:author objects, see person serialization below |
| contributors |
array of serialized atom:contributor objects, see person serialization below |
| links |
array of serialized atom:link objects |
| categories |
array of serialized atom:category objects |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
| inreplyto |
array of serialized thr:in-reply-to elements |
| replies |
array of serialized "replies" links with comment counts |
| licenses |
array of serialized "license" links |
Serializing atom:category
| Field |
Description |
| term |
atom:category/@term |
| label |
atom:category/@label |
| scheme |
atom:category/@scheme (absolute uri) |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
Serializing atom:generator
| Field |
Description |
| version |
atom:generator/@version |
| uri |
atom:generator/@uri |
| value |
atom:generator/text() |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
Serializing atom:link
| Field |
Description |
| href |
atom:link/@href |
| rel |
atom:link/@rel |
| hreflang |
atom:link/@hreflang |
| title |
atom:link/@title |
| length |
atom:link/@length |
| type |
atom:link/@type |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in-scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
Serializing atom:person
| Field |
Description |
| name |
atom:author/@name or atom:contributor/@name |
| email |
atom:author/@email or atom:contributor/@email |
| uri |
atom:author/@uri or atom:contributor/@uri (absolute uri) |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in-scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
Serializing Atom Text constructs (e.g. atom:title, atom:summary, etc)
| Field |
Description |
| type |
"text", "html", or "xhtml" |
| value |
string or xhtml hash |
| display |
string |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in-scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
| base |
in-scope xml:base |
XHTML content is serialized as a structure of hash objects within the value field. For a displayable version, use the display field.
Serializing atom:content
| Field |
Description |
| type |
"text", "html", "xhtml" or MIME media type |
| value |
string or xhtml hash |
| display |
string (only when type equals text, html or xhtml) |
| src |
atom:content/@src |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in-scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
| base |
in-scope xml:base |
XHTML content is serialized as a structure of hash objects within the value field. For a displayable version, use the display field.
Serializing app:control
| Field |
Description |
| draft |
true or false, app:control/app:draft |
Serializing app:service
| Field |
Description |
| workspaces |
array of serialized app:workspace objects |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
Serializing app:workspace
| Field |
Description |
| collections |
array of serialized app:collection objects |
| title |
app:workspace/atom:title |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
Serializing app:collection
| Field |
Description |
| href |
app:collection/@href |
| title |
app:collection/atom:title |
| accept |
array of MIME media types |
| categories |
array of serialized app:categories objects |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
Serializing app:categories
| Field |
Description |
| fixed |
true or false, app:categories/@fixed |
| scheme |
app:categories/@scheme |
| categories |
array of serialized atom:category objects |
| extensions |
array of serialized extension objects (any element not in the Atom namespace) |
| attributes |
array of serialized extension attributes ( any attribute not in the Atom namespace ) |
Serializing thr:in-reply-to
| Field |
Description |
| ref |
thr:in-reply-to/@ref |
| href |
thr:in-reply-to/@href |
| type |
thr:in-reply-to/@type |
| source |
thr:in-reply-to/@source |
Serializing extension elements
| Field |
Description |
| qname |
serialized QName object |
| dir |
rtl or ltr if Atom Bidi Attribute extension is used |
| language |
in-scope xml:lang |
| whitespace |
false if insignificant whitespace should be ignored. equivalent to xml:space |
| base |
in-scope xml:base |
| attributes |
array of serialized attributes |
| children |
array of serialized children |
Serializing attributes
| Field |
Description |
| qname |
serialized QName object |
| value |
string value |
Serializing QName
| Field |
Description |
| name |
QName localpart |
| ns |
QName namespace URI |
| prefix |
QName prefix |
Accessing the serialized data
var feed = { json serialized feed }
document.write( feed.id );
document.write( new Date(feed.updated) );
document.write( feed.title.display );
document.write( feed.title.type );
document.write( feed.entries.length );
for (n = 0; n < feed.entries.length; n++) {
entry = feed.entries[n];
document.write( entry.id );
document.write( entry.title.display );
document.write( entry.title.type );
document.write( entry.content.display );
document.write( entry.content.type );
for (i = 0; i < entry.links.length; i++) {
link = entry.links[i];
document.write( link.rel );
document.write( link.href );
document.write( link.title );
}
}