[Playlist] Re: xspf over json

Chris Anderson jchris at mfdz.com
Sun Apr 29 09:13:40 UTC 2007


Jay,

Thanks for the enlightening feedback. You've given me a framework in
which to evaluate various mime type possibilities. I agree with your
other assessment that web app developers don't care so much how data
is represented, so long as the basic structure is maintained. "The
hash in the sky."

> If this is correct, application/xspf+json doesn't work because a XSPF
> document isn't more generally a json document. I think you'd want:
> application/jspf+json: It's specifically a jspf document, which is more
> generally a json document.

I'd like for the mime type to reflect the fact that jspf is based on
xspf, although I can't see a way to do it while maintaining the
"specific + general" rule.

Your suggestion, application/jspf+json, passes the specific+general
test, but doesn't capture jspf's (tenuous) relation to xspf. Once we
know we're dealing with xspf's ontology, we can take shortcuts that
xml's fussiness won't allow.

Where the xspf spec says "xspf:track elements MAY contain zero or more
location elements", we store an array of locations on the json object
(as opposed to a series of location elements). On the other hand,
because it says "xspf:track elements MAY contain exactly one title",
we can simply store the title as an attribute directly on the json
object.

A general xml to json translation can't take these shortcuts. The big
win for locking jspf to xspf is interoperability. The world will be
using a lightweight json playlist format, and by building it as a
transform from xspf, we allow javascript application developers the
ability to share libraries based around a standard format, as well as
a reference parser implementation that allows them to import xspf
files to javascript objects for use in their applications.

I suppose there's nothing wrong with the jspf spec being the reference
xspf parser written in javascript. I'll gladly contribute what I've
got so far, although I've noted it's incompleteness already.

The xspf parser is attached. It's known to work in Firefox and Safari.
I have a small test suite as well, but that can wait until I find a
nice public svn respository to put it in.

I'll be putting it under either the GPL or MIT license. Feedback is appreciated.


-- 
Chris Anderson
http://jchris.mfdz.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xspf_parser.js
Type: application/x-javascript
Size: 3780 bytes
Desc: not available
Url : http://lists.musicbrainz.org/pipermail/playlist/attachments/20070429/446009d1/xspf_parser.js


More information about the Playlist mailing list