[Catalyst] JSON encoding issue: array of hashes
Dan
dan at entropy.homelinux.org
Sun Aug 29 07:13:41 GMT 2010
Hi people :)
Catalyst beginner here. I'm trying to get an array of hashes encoded.
Something is going wrong.
My code:
---
sub getRetailers :Path :Args(1) {
my ( $self, $c ) = @_;
my $results = $c->model('ESDB::Retailer')->search_literal( '1=1' );
my @results;
foreach my $result ( $results->all ) {
push( @results, {
id => $result->retailerid,
label => $result->retailername
} );
};
$c->stash( @results );
$c->forward('EasySaver::View::JSON');
}
---
Output:
{"HASH(0x9f8bf88)":{"label":"AGL","id":"4"},"HASH(0xa4dbfb8)":{"label":"Integral","id":"2"}}
---
So obviously the HASH(memory location) stuff is wrong. And also I see 2
records there, id 2 and id 4. I'm missing id 1 and id 3.
Anyone know what I'm doing wrong?
Thanks :)
Dan
More information about the Catalyst
mailing list