NAME
Data::Format::Pretty::JSON - Pretty-print data structure as JSON
VERSION
version 0.07
SYNOPSIS
use Data::Format::Pretty::JSON qw(format_pretty);
print format_pretty($data);
Some example output:
format_pretty({a=>1, b=>2})
1:{ 2: "a" : 1, 3: "b" : 2, 4:}
By default color is turned on (unless forced off via
COLOR
environment) as well as pretty printing (unless turned off via pretty=>1) and line numbers (unless when pretty=>0 or turned off by linum=>0).format_pretty({a=>1, b=>2}, {pretty=>0});
{"a":1,"b":2}
DESCRIPTION
This module uses JSON to encode data as JSON.
FUNCTIONS
format_pretty($data, \%opts)
Return formatted data structure as JSON. Options:
color => BOOL
Whether to enable coloring. The default is the enable only when running interactively. Currently also enable line numbering.
pretty => BOOL (default: 1)
Whether to pretty-print JSON.
linum => BOOL (default: 1 or 0 if pretty=0)
Whether to add line numbers.
content_type() => STR
Return application/json
.
ENVIRONMENT
COLOR => BOOL
Set color
option (if unset).
LINUM => BOOL
Set linum
option (if unset).
SEE ALSO
AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.