[occi-wg] JSON rendering

Ralf Nyren ralf at nyren.net
Wed Jul 20 15:38:15 CDT 2011


Hi,

I missed last weeks IRC session but read the chat-log. I very much agree  
that an easy-to-parse media type is needed and since I have been talking  
about a JSON rendering for almost a year now I have made available what I  
got so far.

I used your idea to keep a copy of the Categories in the HTTP header  
although I render all Categories in JSON as well. Much easier to parse  
that way for e.g. an AJAX client.

Examples do tend to speak best so please find 3 example outputs attached:

single_resource.txt - JSON rendering of a single resource instance. Note  
that the Category header is present.

all_resources.txt - JSON rendering of all resource instances, i.e the  
result of a GET / HTTP/1.1. Note that no Category headers are present  
here, they are not usable for collections. The compute is linked to the  
storage using a storagelink so you can see the link rendering etc.

discovery.txt - JSON rendering of the discovery interface

The occi-py demo is updated with JSON rendering support so please feel  
free to try it out. Simple specify 'Accept: application/json' in your  
request to get JSON rendering. JSON parsing for POST/PUT is not yet  
available so use text/occi or text/plain for creating new resource  
instances.

I used 'application/json' media type for the demo but I guess  
application/occi+json would be more appropriate. In that case we should  
probably migrate text/plain to application/occi+text as well...

Example commands:
curl -i -X POST -H 'accept: application/json'  
http://www.nyren.net/api/compute/
curl -i -X GET -H 'accept: application/json' http://www.nyren.net/api/
curl -i -X GET -H 'accept: application/json'  
http://www.nyren.net/api/storage/
curl -i -X GET -H 'accept: application/json' http://www.nyren.net/api/-/

regards, Ralf
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: single_resource.txt
Url: http://www.ogf.org/pipermail/occi-wg/attachments/20110720/1c5531cd/attachment.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: all_resources.txt
Url: http://www.ogf.org/pipermail/occi-wg/attachments/20110720/1c5531cd/attachment-0001.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: discovery.txt
Url: http://www.ogf.org/pipermail/occi-wg/attachments/20110720/1c5531cd/attachment-0002.txt 


More information about the occi-wg mailing list