Because of an XSS exploit, you don't want to have an array as the outer structure. So the examples become:
{"foo": "output for foo"}
or this:
{"multiple": [{"foo": "output for foo"}, {"foo": "another output for foo"}]}
You'll notice we have to come up with some kind of key that is then a magic key / reserved word for ease of processing. However, if we wrap all responses in an object, and always use an array, the examples become more consistent and we don't have to worry about reserved words. The examples become more like:
{"output": [{"foo": "output for foo"}]}
or this:
{"output": [{"foo": "output for foo"}, {"foo": "another output for foo"}]}
Then there becomes asymmetry with input and output request. So then maybe it becomes a good idea to make input request bodies look like this:
{"input": {"qux": "input for qux"}}
Since there is always only one input, wrapped it in an array is unnecessary. You could also make the array optional in the output format to make it less verbose, but it's certainly easier to process with it always being the same structure.
Thoughts?
--
Jeff Lindsay
http://progrium.com