I love GT::JSON
Here is a global that produces a list of categories in JSON:
use GT::JSON;
my $category = $DB->table('Category');
$category->select_options('ORDER BY Full_Name');
my $sth = $category->select(['Has_New_Links','Newest_Link','Number_of_Links','ID','FatherID','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
encode_json { categories_json => \@cats };
}
Example:
http://slashdemocracy.org/...ge.cgi?page=CatsJSON

Here is a global that produces a list of categories in JSON:
Code:
sub { use GT::JSON;
my $category = $DB->table('Category');
$category->select_options('ORDER BY Full_Name');
my $sth = $category->select(['Has_New_Links','Newest_Link','Number_of_Links','ID','FatherID','Name','Full_Name'] );
my @cats;
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = "$CFG->{build_root_url}/" . $category->as_url($cat->{Full_Name}) . "/$CFG->{build_index}";
push @cats, $cat;
}
encode_json { categories_json => \@cats };
}
Example:
http://slashdemocracy.org/...ge.cgi?page=CatsJSON