forked from lix-project/hydra
ToJSON: serialize string_columns to JSON
If the column is undefined, then it should be an empty string according to your API spec.
This commit is contained in:
parent
f0ede5f8b8
commit
50fab154a4
|
@ -18,6 +18,10 @@ sub TO_JSON {
|
||||||
$json{$column} = $self->get_column($column);
|
$json{$column} = $self->get_column($column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach my $column (@{$hint->{string_columns}}) {
|
||||||
|
$json{$column} = $self->get_column($column) // "";
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $column (@{$hint->{boolean_columns}}) {
|
foreach my $column (@{$hint->{boolean_columns}}) {
|
||||||
$json{$column} = $self->get_column($column) ? JSON::true : JSON::false;
|
$json{$column} = $self->get_column($column) ? JSON::true : JSON::false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ __PACKAGE__->many_to_many("usernames", "projectmembers", "username");
|
||||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+4yWd9UjCyxxLZYDrVUAxA
|
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+4yWd9UjCyxxLZYDrVUAxA
|
||||||
|
|
||||||
my %hint = (
|
my %hint = (
|
||||||
columns => [
|
string_columns => [
|
||||||
"name",
|
"name",
|
||||||
"displayname",
|
"displayname",
|
||||||
"description",
|
"description",
|
||||||
|
|
|
@ -25,11 +25,11 @@ my $projectinfo = request(GET '/project/tests',
|
||||||
|
|
||||||
ok($projectinfo->is_success);
|
ok($projectinfo->is_success);
|
||||||
is(decode_json($projectinfo->content), {
|
is(decode_json($projectinfo->content), {
|
||||||
description => undef,
|
description => "",
|
||||||
displayname => "",
|
displayname => "",
|
||||||
enabled => JSON::true,
|
enabled => JSON::true,
|
||||||
hidden => JSON::false,
|
hidden => JSON::false,
|
||||||
homepage => undef,
|
homepage => "",
|
||||||
jobsets => [],
|
jobsets => [],
|
||||||
name => "tests",
|
name => "tests",
|
||||||
owner => "root"
|
owner => "root"
|
||||||
|
|
Loading…
Reference in a new issue