Wednesday, April 19, 2017

update on Gedit plugin to format JSON

what changed: $j->canonical([1]) - this will sort the keys in the json objects

#!/usr/bin/env perl 

use strict;
use JSON::XS;
local $/ = undef;
my $content = ;

my $j = JSON::XS->new->utf8->pretty(1);
$j->canonical([1]);
my $output = $j->encode($j->decode($content));

print $output;