Passing javascript arrays arguments error

Striky2 - April 29, 2008 - 18:30
Project:JSON server
Version:5.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Striky2
Status:postponed (maintainer needs more info)
Description

Hey,

I'm using 100% json-server for my new module collect_nodes. Json-server is really great!
So if you need some advanced usecases example (either widget client side or service side), feel free to have a look.

Ok, I have an issue with passing an argument which is a javascript associative array through the json server. It's not well understood by the json server classes, so at the end, Drupal Service replies a "missing argument". I use the trick to make it a coma-separated string, and to convert the string in array on the server-side, but this is not a "reliable solution".

Any idea how to solve this ? By the way, this seems to me like a more generic issue, the kind of issues interoperability norms are written for. So I was wondering what was the parameters norms (defined types) that Drupal Service understand, what are those that json server understand, ...and so on. I worked once with interoperability issues between .net and J2EE services, and we had to write some rules to ensure a full interop, so I'm guessing it's the same here right?

Bye

#1

eliosh - May 13, 2008 - 17:11
Version:5.x-1.x-dev» 5.x-1.0

I found a solution, modifing js source code.
My patch is this :

  _makeURI: function(data_original) {
    var data = data_original.slice(0);
    output = data.shift();
    for (i in data) {
      output += '['+ data[i] +']';
    }
    return output;
  },

At least, i make a copy of the original array passed, and so i can use it without problem.

Hope it helps.

#2

Striky2 - May 14, 2008 - 13:44

Thx for the post, I'll try this next week and I'll keep you updated.

#3

andremolnar - October 29, 2008 - 23:30
Status:active» postponed (maintainer needs more info)

So I was wondering what was the parameters norms (defined types) that Drupal Service understand, what are those that json server understand

Check out the handbook pages for services module. Its also worth checking out some of the screencasts.
Basically each service/method defined via the services API defines the number and type of arguments that it will accept.
See: http://drupal.org/node/118126
And: http://drupal.org/handbook/modules/services for general info

Provided your client application posts the correct arguments the correct way - services module will respond appropriately

As for the json_server.js file. I'm considering removing it along with json_load from the module and putting it into an example module that is packaged with the json_server.module. Really it is only one suggested way of making use of json_server from the client side.

marking this as needs more info for now to leave things open for discussion

#4

greenmachine - March 13, 2009 - 09:35

+1 to the patch in #1, at least for the 5.x release. The example (http://drupal.org/node/305819) doesn't work unless this patch is in place, could trip up people trying this module out (as it did me). Works after the patch.

#5

tritao - March 31, 2009 - 16:04

I'm using json_server on drupal 6.10, to invoke a views service with javascript.

Passing javascript arguments seems not to be working on version 6 too. I know it's still on development, but I wonder if there's already a workaround...?

Passing one character works fine, trying to pass a number with more than two digits or a string with more than one character, single argument or array, is not working, it's like the view is not receiving the argument ...

 
 

Drupal is a registered trademark of Dries Buytaert.