Skip to content

Instantly share code, notes, and snippets.

@shishkin

shishkin/order.js

Created May 21, 2012
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@shishkin shishkin commented May 21, 2012

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