X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/c0b0123313d8a4895d1c42c8f74675a2be5b6e08..e58e4983aac0a969a6476a7ae0ee6aab25771148:/parse-wormedit diff --git a/parse-wormedit b/parse-wormedit index bc0d926..8c2f2c9 100755 --- a/parse-wormedit +++ b/parse-wormedit @@ -413,9 +413,26 @@ else { # output with user-preferred formatting if ($opt{raw}) { - require JSON::XS; - my $output = JSON::XS->new->ascii->canonical->pretty->allow_nonref; - print $output->encode($data), "\n"; + # full data in yaml (human-readable) formatting + require YAML; + local $YAML::CompressSeries; + $YAML::CompressSeries = 0; + my $yml = "# Wormy levelset\n" . YAML::Dump($data); + + # inline format of short hashes + $yml =~ s{ + ^(\ *) - \n # array indicator + ((?:\1\ \ [a-z0-9]{1,5}:\ *\d+\n)+) # simple hash declaration + (?!\1\ ) # no further children + }[ + my ($indent, $value) = ($1, $2); + chop $value; + $value =~ s/^ +//gm; + $value =~ s/\n/, /g; + "$indent- {$value}\n"; + ]egmx; + + print $yml; } else { print $data->{name};