diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-19 18:56:51 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-19 18:56:51 +0100 |
commit | 3942a2961b4c78392ea44a554b7c71277664201a (patch) | |
tree | 3ba468ac441b81438a49aee450dc21e619497b82 | |
parent | 85fb4e7f3ea9986a65d768be8aa0fb9bd6dd67fe (diff) |
switch to new output format
-rwxr-xr-x | bin/db-wagenreihung-to-json | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/bin/db-wagenreihung-to-json b/bin/db-wagenreihung-to-json index 98107f5..7c279c0 100755 --- a/bin/db-wagenreihung-to-json +++ b/bin/db-wagenreihung-to-json @@ -351,9 +351,7 @@ for my $line (@lines) { $state = "wagonorder"; push( @{ $wagon_map{$number} }, [ $+{type}, $+{number} ] ); - #$map{$number}{has_wagon}{$1} = \1; - - $map{$number}{wagons}{$1} = \1; + $map{$number}{has_wagon}{$1} = \1; } if ( $state eq "conditions" and length($line) and $line =~ m{ \S }x ) { @@ -393,8 +391,7 @@ for my $train_number ( keys %map ) { next; } - #push(@{$map{$train_number}{wagon_list}}, $wagon); - $map{$train_number}{wagon}{ $wagon->[1] } = $wagon_type; + push( @{ $map{$train_number}{wagons} }, $wagon ); if ( $bincount{$wagon_number} > 1 ) { if ( $type_by_wagon_number{$wagon_number}[0] ne $type_by_wagon_number{$wagon_number}[1] ) @@ -410,11 +407,15 @@ for my $train_number ( keys %map ) { # parse/handle that yet. delete $map{$train_number}{type}; delete $map{$train_number}{short}; - delete $map{$train_number}{wagon}; + delete $map{$train_number}{wagons}; delete $map{$train_number}{has_wagon}; } } # use canonical output (i.e., sort hash keys) to allow for easy diffing. -#say JSON->new->utf8->canonical->encode( {valid => {%valid}, train => {%map}} ); -say JSON->new->utf8->canonical->encode( {%map} ); +say JSON->new->utf8->canonical->encode( + { + valid => {%valid}, + train => {%map} + } +); |