I'm unclear on the actual change you're proposing, as RPC treats all responses identically as well. It takes the actual data, be it a single object or a list of objects, returned and wraps it in a JSON-RPC Response object [1], which has an 'id' and 'result' property.
If the response is a collection, extra information (startIndex, totalResults, etc.) is returned in either case.
REST Response to request for single person
HTTP/1.x 200 OK
<OpenSocial-Person>
RPC Response to request for single person
HTTP/1.x 207 Multi-Status
{
"id" : "myself"
"result" : <OpenSocial-Person>
}
REST Response to request for list of people
HTTP/1.x 200 OK
<OpenSocial-Collection<OpenSocial-Person>>
RPC Response to request for single person
HTTP/1.x 207 Multi-Status
{
"id" : "myfriends"
"result" : <OpenSocial-Collection<OpenSocial-Person>>
}
Digging a bit deeper, there is an inconsistency in the OpenSocial Collection object.
In REST it is defined as [2]:
{
"startIndex" : 1,
"itemsPerPage" : 10,
"totalResults" : 100,
"entry" : [
{...first item...},
{...second item...}
...
]
}
while in RPC it is defined as [3]
{
"totalResults" : <total number of elements in the full list>,
"startIndex" : <0 based offset in the full-list of the returned sublist>,
"itemsPerPage" : <total number of elements in the returned sublist>,
"isFiltered" : <boolean indicating if the result honors filter params in the request>,
"isUpdatedSince" : <boolean indicating if the result honors the updatedSince param in the request>,
"itemsPerPage" : <total number of elements in the returned sublist>,
"list" : [ ... the sublist ...]
}
In REST we call it "entry", in RPC we call it "list".
I think "entry" is more appropriate based on the existing XML <--> JSON mapping rules (RPC spec's Overview section [4] has a more detailed version than REST for this point):
Plural fields are encoded as arrays in JSON and repeated tags in XML,
e.g. "fields": [ "value1", "value2" ]
and<fields>value1</field><fields>value2</field>
respectively.
(n.b. the typo: <fields></field> (open tag is plural, close tag is singular))
Otherwise we'd end up with { list: ["foo", "bar"] } being equivalent to
<list>foo</list>
<list>bar</list>
-Lane
[1]
http://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal
[2]
http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/REST-API.html#rfc.section.3.1[3]
http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/RPC-Protocol.html#rfc.section.6
[4]
http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/RPC-Protocol.html#rfc.section.2