Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add shortcut module: CompactJSON

  • Loading branch information...
commit 36b546d340c8683a701b6bc8ac380fd4f9221903 1 parent 63ac6fc
Steven Haryanto (on PC) authored
Showing with 68 additions and 0 deletions.
  1. +5 −0 Changes
  2. +63 −0 lib/Data/Format/Pretty/CompactJSON.pm
View
5 Changes
@@ -1,5 +1,10 @@
Revision history for Data-Format-Pretty-JSON
+0.02 2011-08-11
+
+ - Add ::CompatJSON shortcut module.
+
+
0.01 2011-08-11
- First release.
View
63 lib/Data/Format/Pretty/CompactJSON.pm
@@ -0,0 +1,63 @@
+package Data::Format::Pretty::CompactJSON;
+
+use 5.010;
+use strict;
+use warnings;
+
+use Data::Format::Pretty::JSON;
+
+require Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(format_pretty);
+
+my $json = JSON->new->utf8->allow_nonref;
+
+# VERSION
+
+sub format_pretty {
+ my ($data, $opts0) = @_;
+ my %opts = $opts0 ? %$opts0 : ();
+ $opts{pretty} = 0;
+ Data::Format::Pretty::JSON::format_pretty($data, \%opts);
+}
+
+1;
+# ABSTRACT: Pretty-print data structure as compact JSON
+__END__
+
+=head1 SYNOPSIS
+
+ use Data::Format::Pretty::CompactJSON qw(format_pretty);
+ print format_pretty($data);
+
+Some example output:
+
+=over 4
+
+=item * format_pretty({a=>1, b=>2});
+
+ {"a":1,"b":2}
+
+=back
+
+
+=head1 DESCRIPTION
+
+This module is a shortcut for using L<Data::Format::Pretty::JSON> with options
+C<pretty>=0.
+
+
+=head1 FUNCTIONS
+
+=head2 format_pretty($data, \%opts)
+
+Return formatted data structure as JSON. See L<Data::Format::Pretty::JSON> for
+details.
+
+
+=head1 SEE ALSO
+
+L<Data::Format::Pretty::JSON>
+
+=cut
+
Please sign in to comment.
Something went wrong with that request. Please try again.