parse-wormedit: json format option
[wormy.git] / parse-wormedit
index cf1798d6a25e6cb787b9836577add8782ec93aed..aa220513657bfdaf49507b9311e97ea627334025 100755 (executable)
@@ -54,7 +54,7 @@ else {
 
 if ($opt{output}) {{
        # derive format from file extension
-       if ($opt{output} =~ /\.(yaml|txt)$/) {
+       if ($opt{output} =~ /\.(yaml|json|txt)$/) {
                $opt{format} //= $1
        }
        else {
@@ -70,6 +70,10 @@ if ($opt{output}) {{
 
 # output with user-preferred formatting
 given ($opt{format}) {
+when ('json') {
+       require JSON;
+       say JSON->new->encode($data);
+}
 when ('yaml') {
        # full data in yaml (human-readable) formatting
        require YAML;
@@ -201,6 +205,10 @@ Plain text summary of levelpack contents.
 
 All parsed data in YAML syntax.
 
+=item json
+
+Parsed data in JSON syntax.
+
 =item pnm, png, bmp, ...
 
 Image drawing of rendered levels.