Unverified Commit 9b514055 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add TO_JSON function

parent 37801cde
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -183,6 +183,25 @@ sub errstr {
	return $self->{errstr};
}

sub TO_JSON {
	my ($self) = @_;

	# ensure that all objects are available
	$self->direction;
	$self->origins;
	$self->destinations;
	$self->train_numbers;
	$self->train_descriptions;
	$self->wagons;
	$self->{platform} = $self->platform;

	my %copy = %{$self};

	delete $copy{from_json};

	return {%copy};
}

sub direction {
	my ($self) = @_;