Skip to content

Instantly share code, notes, and snippets.

@shishkin
Created May 21, 2012 17:03
Show Gist options
  • Save shishkin/2763291 to your computer and use it in GitHub Desktop.
Save shishkin/2763291 to your computer and use it in GitHub Desktop.
JSON templates
{
"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" ]
}
}
]
}
}
}
@shishkin
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment