I’m playing around with JSON and SRU.  My server has pretty decent support for content negotiation and I’ve started explaining to it how to handle requests for JSON.




That’s a simple name search, with a request that the response be in JSON.  You’ll notice that the recordPacking is “xml”, which is appropriate, because the records are returned as XML.  But, as far as JSON is concerned, what I returned was a string.  (The value of recordData in JSON is of type string.)  What happens if I want to return JSON records?  How do I even ask for JSON records? 


Right now, to return JSON records I have to say that the recordPacking is “string” (because it sure isn’t “xml”) and pick a recordSchema of JSON (because there’s no other place to say you want JSON.




I think the recordPacking was intended to be the mimeType of the record, as opposed to the httpAccept, which is the mimeType of the response.  I think the recordSchema was intended to talk about the logical content of the record, not the physical format.  In my particular case, I already have multiple schemas that I want to return my data in (LinkedData, Marc21, VIAFCluster), regardless of the mimeType that the record is returned in.


My suggestion is that we expand the meaning of recordPacking to mean mimeType of the recordData and grandfather in the special values of “string” to mean “text/plain” and “xml” to mean “text/xml”.  If you return text/plain records in a text/xml response, it is up to the application to make the records safe in the XML (meaning escaping the appropriate characters in the string.)  That same would be expected in JSON (where the string would just get quotes around it.)


Does this seem sensible?  Is anyone else doing anything like this?