Permalink
Browse files

'home' migration: Make jsontidy into a script.

  • Loading branch information...
1 parent bbacba6 commit 9328f7805271eb5c34d487b6648dc85083d9b8c7 @norm committed May 8, 2010
Showing with 21 additions and 17 deletions.
  1. +21 −0 bin/jsontidy
  2. +0 −17 etc/bash/rc/code
View
21 bin/jsontidy
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+# github:norm:homedir:bin/jsontidy
+# -*- Mode: Perl; tab-width: 4; indent-tabs-mode: nil; -*-
+#
+# Reformat JSON to be more readable.
+
+use 5.10.0;
+use JSON;
+
+foreach my $file ( @ARGV ) {
+ my $json_data = from_json(
+ $file,
+ { allow_nonref => 1 }
+ );
+ my $output = to_json(
+ $json_data,
+ { pretty => 1 }
+ );
+
+ say $output;
+}
View
17 etc/bash/rc/code
@@ -1,17 +0,0 @@
-# ~/etc/bash/rc/code
-# -*- Mode: Bash; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-#
-# working with code of various sorts
-
-export PYTHONLIB="${HOME}/lib/python"
-
-function jsontidy {
- perl -MJSON -nE'
- say to_json(
- from_json(
- $_,
- { allow_nonref => 1 }
- ),
- { pretty => 1 }
- );' "$@"
-}

0 comments on commit 9328f78

Please sign in to comment.