Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created December 5, 2015 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/b4aef7b4562716373353 to your computer and use it in GitHub Desktop.
Save bessarabov/b4aef7b4562716373353 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
=encoding UTF-8
=cut
=head1 DESCRIPTION
=cut
# common modules
use strict;
use warnings FATAL => 'all';
use feature 'say';
use utf8;
use open qw(:std :utf8);
use DDP;
use Carp;
use File::Slurp;
use JSON::PP;
# global vars
# subs
# main
sub main {
my $json_coder = JSON::PP
->new
->pretty
->canonical
->indent_length(4)
;
my $i = 1;
my $j = 1;
my $data = {
one => [
0..5,
'a',
],
two => {
foo => { map { $_ => $i++ } 'a'..'z' },
bar => { map { $_ => $j++ } 'a'..'z' },
},
};
write_file('one.json', $json_coder->encode($data));
$data->{one}->[6] = 'b';
$data->{two}->{foo}->{g} = 19;
write_file('two.json', $json_coder->encode($data));
}
main();
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment