Created
          May 21, 2012 17:03 
        
      - 
      
- 
        Save shishkin/2763291 to your computer and use it in GitHub Desktop. 
    JSON templates
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "order": { | |
| "href": "http://...", | |
| "method": "POST", | |
| "template": { | |
| "location": "", | |
| "@location": { | |
| "prompt": "Enter your postal code" | |
| }, | |
| "pickupTime": "", | |
| "@pickupTime": { | |
| "prompt": "When do you want to pickup your order?", | |
| "type": "dateTime" | |
| }, | |
| "items": [ | |
| { | |
| "name": "espresso", | |
| "@name": { "options": [ "espresso", "cappuchino", "latte" ] } | |
| "size": "normal", | |
| "@size": { "options": [ "normal", "grande", "venti" ] }, | |
| "additions": [], | |
| "@additions": { | |
| "multiple": true, | |
| "item": "string", | |
| "options": [ "shot", "caramel", "vanilla", "decaf" ] | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
JSON templates implement a hypermedia control similar to an HTML form. The URL and the HTTP method can be specified along with a template object. The template object should give the client enough information to fullfil the request. If possible, it should already be pre-filled with all the required information. The client can send the template as it is or optionally customize the template, changing the properties it understands. JSON descriptors [https://gist.github.com/2763023] can be used to enhance the template with metadata.