Currently, when you return a numeric array, Zend_Rest_Server will turn
something like this:
$result = array('A','Bit','Of','Data');
Into something like this:
<key_0>A</key_0>
<key_1>Bit</key_1>
<key_2>Of</key_2>
<key_3>Data</key_3>
This works, but can be cumbersome. What would be nicer is something like
this:
<data index="0">A</data>
<data index="1">Bit</data>
<data index="2">Of</data>
<data index="3">Data</data>
The former is easier to iterate over using ActionScript's ObjectProxy and
E4X syntax's. You could just do something like this:
result.data[0]// accesses "A"
result.data[1] // accesses "Bit"
And so forth. This is easier to iterate over than:
result.key_1 // accesses "A"
result.key_2 // accesses "Bit"
This is because you have iterate from n=0 to n={upperLimit}, and then look
in result.data[n], but it's a bit trickier to inspect result.key_{n}.
Anyway, I was wondering there were any plans to add a new, optional behavior
to Zend_Rest_Server so it would be like I described above. I've already
implemented this by changing a few lines in an class method that overrides
Zend_Rest_Server::_structValue. See here:
http://www.zfforums.com/zend-framework-components-13/web-web-services-22/some-zend_rest_server-issues-i-m-having-42.html#post4527
-Josh
--
View this message in context: http://www.nabble.com/Zend_Rest_Server-issues-and-returning-arrays-tp19236018p19236018.html
Sent from the Zend Server mailing list archive at Nabble.com.
没有评论:
发表评论