Skip to content
Snippets Groups Projects
Unverified Commit b60e5eef authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Connection, Section: Add TO_JSON method

parent e73b97dd
No related branches found
No related tags found
No related merge requests found
......@@ -160,6 +160,23 @@ sub sections {
return;
}
sub TO_JSON {
my ($self) = @_;
my $ret = { %{$self} };
for my $k ( keys %{$ret} ) {
if ( ref( $ret->{$k} ) eq 'DateTime' ) {
$ret->{$k} = $ret->{$k}->epoch;
}
if ( ref( $ret->{$k} ) eq 'DateTime::Duration' ) {
$ret->{$k} = [ $ret->{$k}->in_units( 'days', 'hours', 'minutes' ) ];
}
}
return $ret;
}
# }}}
1;
......
......@@ -153,6 +153,23 @@ sub messages {
return;
}
sub TO_JSON {
my ($self) = @_;
my $ret = { %{$self} };
for my $k ( keys %{$ret} ) {
if ( ref( $ret->{$k} ) eq 'DateTime' ) {
$ret->{$k} = $ret->{$k}->epoch;
}
if ( ref( $ret->{$k} ) eq 'DateTime::Duration' ) {
$ret->{$k} = [ $ret->{$k}->in_units( 'days', 'hours', 'minutes' ) ];
}
}
return $ret;
}
# }}}
1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment