Posted by snelson on January 17, 2007 at 9:13pm
A problem I have not found a good solution for is how to handle array and struct input in the service browser. One idea is to use JSON format, and then parse the JSON string into its PHP value, but this would require a JSON parser. The PEAR JSON parser is commonly used, but it is not GPL and I don't want people to have to dowload additional scripts.
Any ideas?

Comments
WDDX
What about WDDX (Web Distributed Data eXchange)?
No extra scripts would be necessary for as long as the server has it enabled (M$ Windows has it by default, other OS must compile PHP with "--enable-wddx"). Oh, and Apache must have the Expat library installed. May be too many things to have to be truly "available". Oh, well.
The module could do a quick check-up of the server and decide if all the requirements are met.
It is an idea about a XML-based way to pass variables around.
Jorge
hmmm
Not sure we're talking about the same thing...
In the service browser, we are able to test methods by inputting arguments into a form field. But what happens when we want to test a method that takes an array or struct argument, like node.save. Ideally, I want to be able to put a node object into the form like this:
{nid:1,title:"Some node",body:"The node body"}
And maybe enter an array arguement in another method like this:
["title","body","nid"]
This by Them
Misunderstood?
May be I am talking about something different. I didn't understand what you want to do.
In the other hand I do not know Services module, although I am interested on it. I will dig into it as soon as my dev server comes back to live.
Jorge
I would imagine WDDX to be
I would imagine WDDX to be implemented as another server module, in addition to XMLRPC and AMFPHP. What I was talking about here is the service browser, which allows you to browse and test all remote methods available from the Drupal interface. You'll have to try it out to see what I mean. The problem is that there is no good way to test methods with array or struct arguments. What I'm talking about here is ways to be able to input those data types into a form field, in the service browser for testing.
This by Them
I'd like to see the final info in the Services Documentation
I'm always having to explain to someone how to parse in arguments, and I myself have questions about adding nodes with module/CCK arguments. Any of this info would be perfect for the docs. I can help.
Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant
I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us
Is there a solution?
I'm not sure if this is the same issue but I'm trying to pull data into my flex app from arrays of a node. For example, how would I grab "Some Value" from a cck field that is an array?
[field_some_field] => Array
(
[0] => Array
(
[value] => Some Value
)
)
Typing in "field_some_field" in the services browser will return a result but referencing the same field name in flex won't output the value. field_some_field[0][value] doesn't work either.
Do you have a custom service module ready?
Do you have a custom service module for your content type? if not, then you're trying to use node.save() right?
If you like PHP more:
You can map it to an AS object in PHP, which seems to be something PHP people are more keen to doing. Hitting the custom field in PHP is easier than doing it all in AS, so far.
If you like ActionScript more:
You can prepare a custom Drupal object to satisfy a node.save(). There a lot of array mapping/wrapping so it's not so fun - we have a class package internally that I'm cleaning up for eventual public consumption which does a lot of the dirty work for custom fields and even multi-dimensional fields (ugh, what a pain).
Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant
I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us
Yes, I have a custom service
Yes, I have a custom service module and even tried pulling arrayed fields with it but I'm running into the same problem as using the views service module. I think I've got the same problem as this person: http://drupal.org/node/162132. So that there's no assumption that my custom service module was created wrong, I'll use the views service module to explain.
Say I have a custom field that is an array named 'field_manufacturer'. This is from using a select field in a node to input a manufacturer. Using:
views.getView("viewname", ['nid','title','body']);I'd like to grab the manufacturer for that node as well as the nid, title, and body fields. However, I think because field_manufacturer is an array, getView is not picking up the value.
I've tried
views.getView("viewname", ['nid','title','body','field_manufacturer']);views.getView("viewname", ['nid','title','body','field_manufacturer[0][value]']);views.getView("viewname", ['nid','title','body','field_manufacturer[0][\'value\']']);Nada.
Inside my datagrid, the nid and title fields are appearing just fine but for the manufacturer, the closest I've got is '[object Object]'
Thanks for any help. I've combed through the drupal site for answers but still stuck.
Here's one way
I also don't know if your specific question is exactly on-topic, but I've been struggling with it myself, and here's one way I found to get at the value for a cck field -- loop through the returned array elements with a forEach method that calls a function to add a new property to the array (my cck field is "field_other_info"):
public function onViewsResult(event:ResultEvent):void
{
donors = ArrayUtil.toArray(event.result);
donors.forEach(getValues);
}
private function getValues(element:*, index:int, arr:Array):void {
arr[index]["field_other_info_value"] = element.field_other_info["0"]["value"];
}
...
<mx:TextArea x="10" y="242" width="460" height="75" id="otherInfo" text="{donors_select.selectedItem.field_other_info_value}"/>
If I had other cck fields, I could add similar lines to the getValues function. But it seems to me we'd want the service to handle this itself somehow.
Please explain
I'm new to whole implementation of drupal into flex however I'm trying to pull images out of drupal to display in Flex. Following your example I'm not sure how one would call this function with three arguments in flex.
My Code:
Basically I'm just trying to get a file location out of Drupal and into Flex. Thank you
Drupal and Flex yeah!!!!
Drupal and Flex yeah!!!!
Here is a post that describes a patch that fixes the image path
When I was trying to find a way to pass an array of args for the getView function, I stumbled on your answer.
Seppe Staes show how to modify the view service module to include image path.
http://www.myinterface.eu/wordpress/?p=3
Hope this helps,
David Strickland
startup-rescue.com
Follow up?
What happened with this? If there has still not been a decision on which format to use, perhaps this would be the perfect way for me to get into Drupal development. I am very interested in the Services module and have already been peeking in on it's code for D6.
Basically what I'm saying is this. If this issue still exists, let's decide upon a format (PHP object notation? JSON?) and I'll write a patch as quickly as I can!
/R