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:
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.
> 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 athttp://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:
> 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.
> 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: > > 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 athttp://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:
> > 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.
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.
> 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:
> > 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 athttp://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:
> > 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.
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.
> On Dec 12, 9:45 pm, TSchultz55 <TSchult...@gmail.com> wrote:
> > 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:
> > > 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 athttp://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:
> > > 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.
> 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 athttp://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:
> 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.