[JavaScript Client] BUG parsing array

2 views
Skip to first unread message

Pierluigi Taddei

unread,
Aug 25, 2008, 6:25:54 AM8/25/08
to JSON/XML-RPC Client and Server Implementations
There is a bug in the parsing of array variables when sent via GET
protocol.

In particular there is no difference in a plain variable and an array
containing a single element. I.e. variable x is parsed in the same way
as array x

If for instance the server accepts only array arguments this implies
that an error occurs every time a single element is included in the
array

Weston Ruter

unread,
Aug 25, 2008, 9:20:34 AM8/25/08
to json-x...@googlegroups.com
I can definitely see how this would cause a problem. What I recommend for now is that you remove the array type in the function argument list and manually configure that argument in the function, so instead of:

function argtest(array $arg){
    //process arg
}

Do:

function argtest($arg){
    if(!is_array($arg))
        $arg = array($arg);
    //process arg
}

I can look into a workaround in the library itself.
Reply all
Reply to author
Forward
0 new messages