Posted on 2008-12-29 16:40:41-08 by schlmm
params order
Hi,
i have some problems with the order of params.
example:
package MyApp; use base ('JSON::RPC::Procedure'); sub param_test : Obj(a,b,c) { my ($server, $obj) = @_; return $obj; } 1;

request is (send via javascript):
{"method":"param_test","params":["a","b","c"],"version":1.1,"id":"843326301"}

result:
{"version":"1.1","result":{"c":"a","a":"b","b":"c"}}


i think the problem is the order of hashes in perl. but strange is, if i change the code in JSON::RPC::Server (sub _argument_type_check, line 348):
if (my $hash = $type->{names}) { my $i = 0; for my $name (keys %$hash) { $regulated->{$name} = $params->[$i++]; } }

to:
if (my $a = $type->{position}) { my $i = 0; for my $name (@$a) { $regulated->{$name} = $params->[$i++]; } }

then it works fine. mysterious =)

best regards
Georg

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.