JSON APML RFC

5 views
Skip to first unread message

David P. Novakovic

unread,
Dec 11, 2007, 7:14:27 PM12/11/07
to apml-...@googlegroups.com
Request for comments on this proposal for APML-JSON. Cheers.


APML JSON

Rationale

As more and more web applications become APML aware there will be
services delivering "APML-Like" data as JSON, often converted directly
from APML itself. This document seeks to outline a sane specification
for JSON-APML to take the guess work out of it for developers seeking
to do work with APML in Javascript, or even seeking a lightweight
alternative to APML itself. Henceforth in this document the original
APML spec will be referred to as "APML" and the new JSON specification
will be referred to as "APML-JSON".

For the most part this specification will mirror the original APML
specification as closely as possible. The largest difference is that
where a NodeList of Concept/Source nodes with "key" attributes exist
in the APML spec now are replaced with keyword indexed values in a
JSON associative array. This will become clearer in the example.
Another relatively large difference is the use of camelCase for keys
that are capitalised in the XML nodes, rather than all caps. This is a
compromise between the reccomendation of W3 for using no caps with
underscores and the APML all caps way. Naturally people will do what
they want. ;) Additionally, with the JSON version, if fields are
missing, they are just assumed to be empty, this saves having to
transmit redundant markup.

To see an example of javascript using JSON with this notation, head
over to Ben Novakovic's example at http://bmn.name/examples/apml/ .
Look at the source to see the javascript.

Basically the root element contains two main parts, the head and the body:

{
"head":{},
"body":{}
}

The head contains some metadata:

"head": {
"version": 0.6,
"title": "Example APML-JSON file for apml.org",
"generator": "Written by Hand",
"userEmail": "sam...@apml.org",
"dateCreated": "2007-03-11T01:55:00Z"
}

Then the body contains some profiles and also has a default profile:

"body": {
"defaultProfile": "Work",
"profiles": {}
}

Each profile contains explicitdata and implicitdata

"profiles": {
"work": {
"implicitData": {},
"explicitData": {}
}
"home": {
"implicitData": {},
"explicitData": {}
}
}

Explicit data and implicit data are similar with slightly different
attribute, so we'll look aty implicit ones here. There will be
examples of others in the example APML-JSON file that will be at the
end of this documents. Data can be in the form of sources or concepts.

"implicitData": {
"concepts": {
"attention": {
"value": "1.0",
"from": "",
"updated": "2007-03-11T01:55:00Z"
},
"content distribution": {
"value": "1.0",
"from": "GatheringTool.com",
"updated": "2007-03-11T01:55:00Z"
}
},
"sources": {
"http://feeds.feedburner.com/apmlspec": {
"name": "APML.org",
"value": "1.0",
"type": "application/rss+xml",
"value": "0.4"
}
}
}

Sources can also contain an Author.

"http://feeds.feedburner.com/apmlspec": {
"name": "APML.org",
"value": "1.00",
"type": "application/rss+xml",
"value": "0.4"
"author": {
"key": "Sample",
"value": "0.5",
"from": "GatheringTool.com",
"updated": "2007-03-11T01:55:00Z"
}
}

So here we have a full example:

{
"head": {
"version": "0.6",
"title": "Example APML-JSON file for apml.org",
"generator": "Written by Hand",
"userEmail": "sam...@apml.org",
"dateCreated": "2007-03-11T01:55:00Z"
},
"body": {
"defaultProfile": "Work",
"profiles": {
"work": {
"implicitData": {
"concepts": {
"attention": {
"value": "0.1",
"from": "",
"updated": "2007-03-11T01:55:00Z"
},
"content distribution": {
"value": "0.1",
"from": "",
"updated": "2007-03-11T01:55:00Z"
}
},
"sources": {
"http://feeds.feedburner.com/apmlspec": {
"name": "APML.org",
"value": "1.00",
"type": "application/rss+xml"
"author": {
"key": "Sample",
"value": "0.5",
"from": "GatheringTool.com",
"updated": "2007-03-11T01:55:00Z"
}
}
}
},
"explicitData": {
"concepts": {
"attention": {
"value": "0.1"
},
"content distribution": {
"value": "0.1",
}
},
"sources": {
"http://feeds.feedburner.com/apmlspec": {
"name": "APML.org",
"value": "1.00",
"type": "application/rss+xml"
"author": {
"key": "Sample",
"value": "0.5",
}
}
}
}
},
"home": {
"implicitData": {},
"explicitData": {}
}
},
"applications": {
"sample.com": {
"sampleAppEI": {}
}
}
}
}

TSchultz55

unread,
Dec 12, 2007, 6:45:20 AM12/12/07
to APML
Very nice.

Not too familiar with JSON - could you possibly also supply some
examples of how one could extract this information in JavaScript?

Ex: Show me all ImplicitData Concepts for my "Home" profile.

On Dec 11, 7:14 pm, "David P. Novakovic" <davidnovako...@gmail.com>
wrote:

David P. Novakovic

unread,
Dec 12, 2007, 6:55:44 AM12/12/07
to apml-...@googlegroups.com
Yep, check out the source at http://bmn.name/examples/apml/ in
particular you want the function "parseAPML"

very simple! A lot simpler than the code required to parse XML, hence
this suggestion :)

Never fear though, Paul has asked me to provide an XSLT template, so
soon you will be able to convert APML to JSON with minimal of fuss.

David

Ben Novakovic

unread,
Dec 12, 2007, 7:24:24 AM12/12/07
to APML
TSchultz55, JSON is native serialized javascript objects, hence the
JavaScript Object Notation. To parse JSON text into javascript object,
you can simply call eval() around the string. That example script
returns the JSON string wrapped in the parseJSON function call, the
browser then hands the eval()d string to the parseAPML function. As a
result, the parseJSON function just processes the APML JSON data as if
it were native objects.

If you want to read more, you can checkout the wikipedia page
( http://en.wikipedia.org/wiki/JSON ) or the JSON website ( http://json.org
)

Hope this helps.

Ben.

Ben Novakovic

unread,
Dec 12, 2007, 7:34:55 AM12/12/07
to APML
TSchultz55 - to give you a solution to your example request, see
below.


/*
* parseAPML javascript function
* prints all ImplicitData Concepts for the "Home" profile.
*/

// o is a javascript APML object representation
function parseAPML(o) {
var s = '';
//grab the implicitData node in the 'Home' profile
var home = o.body.profiles.Home.implicitData;
for(var k in home) { // for each of the implicit concepts
s += k + "\n";
}
alert(s); //alert the resulting values
}


On Dec 12, 10:24 pm, Ben Novakovic <bennovako...@gmail.com> wrote:
> TSchultz55, JSON is native serialized javascript objects, hence the
> JavaScript Object Notation. To parse JSON text into javascript object,
> you can simply call eval() around the string. That example script
> returns the JSON string wrapped in the parseJSON function call, the
> browser then hands the eval()d string to the parseAPML function. As a
> result, the parseJSON function just processes the APML JSON data as if
> it were native objects.
>
> If you want to read more, you can checkout the wikipedia page
> (http://en.wikipedia.org/wiki/JSON) or the JSON website (http://json.org

David Novakovic

unread,
Dec 14, 2007, 6:13:49 AM12/14/07
to APML
Ok, I found a problem with the spec, it doesn't allow for multiple
authors.

I'll fix that in the version I post to the Wiki.

David

On Dec 12, 10:14 am, "David P. Novakovic" <davidnovako...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages