summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-11-17 21:09:31 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-11-17 21:09:31 +0100
commit1f7b7d9cc2f482d0375ca4993decae0f371c8129 (patch)
treedb47f94098c37a6dd1e54c5addfd82596b4e8452
parent2c20e8ca0c98b7c7b6936b7a3679adc2df7d18d6 (diff)
add json2json (useful to re-gain canonical stations.json format)
-rwxr-xr-xshare/json2json14
1 files changed, 14 insertions, 0 deletions
diff --git a/share/json2json b/share/json2json
new file mode 100755
index 0000000..5cad10f
--- /dev/null
+++ b/share/json2json
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use 5.010;
+
+use File::Slurp qw(read_file write_file);
+use JSON;
+
+my $json_str = read_file('stations.json');
+my $stations = JSON->new->utf8->decode($json_str);
+@{$stations} = sort { $a->{name} cmp $b->{name} } @{$stations};
+my $json_out = JSON->new->utf8->canonical->pretty->encode($stations);
+write_file( 'stations.json', $json_out );